// IsPerfect.java import java.util.*; class IsPerfect { public static void main(String[] args) { int max; int n; Scanner scanner = new Scanner(System.in); System.out.print("Enter max number: "); max = scanner.nextInt(); System.out.println("Here are the perfect #'s up to " + max + ":"); for (n=0; n<=max; n++) { if (isPerfect(n)) { System.out.println(n); } } } public static boolean isPerfect(int n) { int sumOfDivisors; int divisor; if (n < 1) { return false; } sumOfDivisors = 0; for (divisor=1; divisor