判断完全数

 1 package com.lv.jj;
 2 
 3 public class DemoVe {
 4     //1000以内的完全数
 5     public static void main(String[] args) {
 6         for(int i=2;i<=1000;i++){
 7             int count=1;//完全数的定义
 8             for(int j=2;j<=i/2;j++){//每个整数的最大因子不超过它的一半
 9                 if(i%j==0){//若被整除说明j是i的因子
10                     count+=j;
11                 }
12                 
13             }
14             if(i==count){//判断当前数和其因子数是不是相等
15                 System.out.println("完全数是"+count);
16             }
17         }
18 
19     }
20 
21 }

原文地址:https://www.cnblogs.com/dabu/p/12297795.html