- 2

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

Perfect number

29th Aug 2016, 6:51 PM
Abhishek kumar
Abhishek kumar - avatar
2 Respuestas
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); } }
30th Aug 2016, 5:36 PM
SHRIDHAR M PATIL
0
modify it using import java.util.Scanner(); and use for loop
30th Aug 2016, 5:38 PM
SHRIDHAR M PATIL