Perfect Number- If the sum of all the factors of a number is equal to the number itself then it is a perfect number. This program finds whether a given number is perfect number or not.

Example:- 6 = 1+2+3

28 = 1+2+4+7+14

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import java.io.*; class perfectnumber { public static void main()throws IOException { int n,s=; InputStreamReader IR=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(IR); System.out.println("entre a no"); n=Integer.parseInt(br.readLine()); for(int x=1;x<n;x++) if(n%x==) s=s+x; if(s==n) System.out.println("it is perfect no"); else System.out.println("it is not perfect no"); } } |

**OUTPUT:**

Cool is so ccool