-2

How to Print perfect number at least 6 in very quick time.

Perfect number

8/29/2016 6:51:04 PM

Abhishek kumar

2 Answers

New Answer

0

public class Program { public static void main(String[] args) { int n=28; int sum=0; int i=1; while(i<=n/2) { if (n/i==0) { sum =sum+i; } i++; } if(sum==n) { System.out.println("perfect num"+n);} else System.out.println("not perfect no"+n); } }

0

modify it using import java.util.Scanner(); and use for loop