9 lines
176 B
Kotlin
Vendored
9 lines
176 B
Kotlin
Vendored
fun isPerfect(n: Int): Boolean {
|
|
var sum = 1
|
|
for (m in 2..n/2) {
|
|
if (n % m > 0) continue
|
|
sum += m
|
|
if (sum > n) break
|
|
}
|
|
return sum == n
|
|
} |