# Perfect Number in Java

Here you will know about perfect number in Java with program and example.

What is Perfect Number?

The number said to be perfect number when sum of all positive divisors of that number excluding that number itself in divisors is equal to that number.

Or, sum of all positive divisors of that number including that number is 2 times of the number.

Key Points:

• The number of divisors of perfect number will be even.
• Most of the perfect numbers are even numbers.
• Odd numbers are very rare in perfect numbers.
• The digital root of all perfect numbers (except 6) is 1.

Example:

i) 28=2+8=10

1+0=1

ii) 496=4+9+6=19

1+9=10

1+0=1

This will be true for all perfect numbers.

Suppose take 6 is perfect number.

Positive divisors of 6 are 1, 2, 3, 6. We should exclude number in divisors so 6 we need to exclude. Then those divisors are called proper divisors.

Remaining numbers sum is 1+2+3=6

Number = sum of all proper positive divisors.

or

1+2+3+6=12

Number= ½(sum of all positive divisors).

## Program for Perfect Number in Java

Output

enter any positive number
28
28 is a perfect number