Java Program to Check if a given Number is Perfect Number

In this program, you'll learn to Check if a given Number is Perfect Number by creating a class.

A perfect number is a positive integer where the sum of all its positive divisors, except itself, is equal to the number itself.

For example 6 is a perfect number as 1,2 and 3 are its divisors and the sum of divisors=1+2+3=6. Here we have created a program that will take the number from the user and reports whether it is perfect or not.

6= 1+2+3 
28= 1+2+4+7+14 
496= 1+2+4+8+16+31+62+124+248


Check if a given Number is Perfect Number:


When you run the program, the output will be:

Enter Positive Integer
28
Number is Perfect

Previous Post Next Post