int numPerfect(int n) { int count = 0; for(int k = 1; k <= n; k++) { if(isPerfect(k)) { count++; } } return count; }