Algorithm to Check if Number is Perfect Number

[55 views]


What is Perfect Number?

Perfect number is a positive integer equal to the sum of its proper divisors. Sum of its proper divisor excludes the Number itself. Ex. For number 6, the divisors are 1, 2, 3 and 6. Now if we take sum of 1, 2, 3 and exclude the number itself (i.e. 6), the sum is 6. Hence, 6 is a perfect number. 6 is the smallest Perfect Number.

Algorithm to Check if Number is Perfect Number

Let's check another number:
Input: 28
Divisors of 28: 1, 2, 4, 7, 14, 28
Sum of Divisors excluding 28: 1+2+4+7+14=28
Output: 28 is Perfect Number

Algorithm to Check whether given number is Perfect Number:

1. Start 2. Read n 3. Initialize s=0 4. for i=1 to n do a. if(n%i)==0, then b. s=s+i 5. if s==n then Print "Given Number is Perfect Number". Goto Step 7 6. Print "Given Number is Not a Perfect Number" 7. Stop
        

Algorithm Logic Test

Our Quiz prepared by Experts Helps you identify your knowledge in Algorithms. Everyone should atleast attempt this Quiz Once. 



Need any help in Programming? Chat with Us

Comments



Online Compiler
Search
Algorithm Quiz

Only 5% Users were able to score above 75% in this Quiz. Can You Crack this?

Deals Ends in





Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Pseudocode for Perfect Number