bool isPerfect(int n) { // Step 1: Set sum = the sum of the proper divisors of n. int sum = 0; for(int k = 1; k < n; k++) { if(n % k == 0) { sum = sum + k; } } // Step 2: n is perfect if sum == n. return (sum == n); }