这才是真的解出来
完全数计算
http://www.nowcoder.com/questionTerminal/7299c12e6abb437c87ad3e712383ff84
import java.util.*; public class Main{ public static void main(String[] args){ Scanner in=new Scanner(System.in); while(in.hasNext()){ int n=in.nextInt(); System.out.println(count(n)); } } public static int count(int n){ int sum=0; int c=0; for(int j=2;j<=n;j++){ for(int i=1;i<=j/2;i++){ if(j%i==0) sum+=i; } if(sum==j) c++; sum=0; } return c; } }