package com.javaday03;
import java.util.Scanner;
/**
*
* @author Alfred
* @data 2018年7月21日下午2:57:36
* Description:计算给定范围内的完全数
* Version:1.0
*/
public class Demo08 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("请给定完全数的范围:");
int n = sc.nextInt();
System.out.println(n + "以内的完全数有:");
int sum = 0;
for (int i = 0; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (i == j) {
if (sum == i) {
System.out.print(i + " ");
sum = 0;
continue;
} else {
sum = 0;
continue;
}
}
if (i % j == 0) {
sum = sum + j;
}
}
}
}
}