RosettaCodeData/Task/Abundant-deficient-and-perfect-number-classifications/Wren/abundant-deficient-and-perfect-number-classifications-1.wren
2023-07-09 17:42:30 -04:00

18 lines
448 B
Text

import "/math" for Int, Nums
var d = 0
var a = 0
var p = 0
for (i in 1..20000) {
var j = Nums.sum(Int.properDivisors(i))
if (j < i) {
d = d + 1
} else if (j == i) {
p = p + 1
} else {
a = a + 1
}
}
System.print("There are %(d) deficient numbers between 1 and 20000")
System.print("There are %(a) abundant numbers between 1 and 20000")
System.print("There are %(p) perfect numbers between 1 and 20000")