1. A Perfect Number N is a number whose sum of the proper divisors is equal to N. The proper divisors are the numbers that are evenly divisible to N from 1 to N-1.
Example:
1 2 4 7 14 are the proper divisors of 28.

The sum of this number is 28, which is N itself, therefore, 28 is called a PERFECT NUMBER. If the sum of the proper divisors of N is less than N, then N is a Deficient Number. If the sum of the proper divisors of N is more than N, then N is Abundant Number.

Write a program that allows the user to enter the value of N and then displays the result indicating whether the number entered is perfect, deficient or abundant.
Sample Run:
Input a number: 16
The proper divisors of 16 are:
1 2 4 8
Sum of the proper divisors = 15
Therefore, 16 is a deficient number.

1

Answers

2014-09-24T03:52:00+05:30

This Is a Certified Answer

×
Certified answers contain reliable, trustworthy information vouched for by a hand-picked team of experts. Brainly has millions of high quality answers, all of them carefully moderated by our most trusted community members, but certified answers are the finest of the finest.
I write an algorithm. You can write the program.
This is a simple program. Not efficient in computation. you can replace the comparison K < N  by    K <=  (N+1)/2         that is more efficient.
It can be made more efficient by K < square root (N).  But print K and N/K at the same time.  output for N = 32 looks like  1 2 16 4 8 16 

Algorithm Perfect 
begin

   N: Integer - input data
   K : integer   -  current divisor
   Sum : integer - sum of factors

      Print "Input a number : "
      Input N
      Print " The proper divisors of " , N, " are " 
      K = 1
      Sum = 0
        While K <= N do 
                If ( N % K ) = 0  then  // reminder is 0.   K<= (N+1)/2 is more efficient.
                       Print K 
                      Sum = Sum + K
               end if 
              K = K + 1
       end while

      print "Sum of the proper divisors is "  ,  Sum , " Hence "  ,  N 

     If (Sum = N ) then
            Print   " is a  perfect number "
     else if  (Sum < N ) then
          Print   " is a deficient number  "
    else 
         print " is an abundant number "
     end if

end perfect 


0