package 算法;
import java.util.Scanner;
public class 完数 {
static int sum;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner=new Scanner(System.in);
System.out.println(“测试的数:”);
int num=scanner.nextInt();
f(num);
//完数:能被小于此数整除的数相加等于此数
System.out.println(sum==num?sum:0);
}
private static void f(int num) {
for(int i=num-1;i>0;i–){
if(num%i==0){
sum=sum+i;
}
}
}
}