func isPerfect(num) { var sum = 0 for i in 1..