44 lines
731 B
Text
44 lines
731 B
Text
divisorSum = function(n)
|
|
ans = 0
|
|
i = 1
|
|
while i * i <= n
|
|
if n % i == 0 then
|
|
ans += i
|
|
j = floor(n / i)
|
|
if j != i then ans += j
|
|
end if
|
|
i += 1
|
|
end while
|
|
return ans
|
|
end function
|
|
|
|
cnt = 0
|
|
n = 1
|
|
while cnt < 25
|
|
sum = divisorSum(n) - n
|
|
if sum > n then
|
|
print n + ": " + sum
|
|
cnt += 1
|
|
end if
|
|
n += 2
|
|
end while
|
|
|
|
while true
|
|
sum = divisorSum(n) - n
|
|
if sum > n then
|
|
cnt += 1
|
|
if cnt == 1000 then break
|
|
end if
|
|
n += 2
|
|
end while
|
|
|
|
print "The 1000th abundant number is " + n + " with a proper divisor sum of " + sum
|
|
|
|
n = 1000000001
|
|
while true
|
|
sum = divisorSum(n) - n
|
|
if sum > n and n > 1000000000 then break
|
|
n += 2
|
|
end while
|
|
|
|
print "The first abundant number > 1b is " + n + " with a proper divisor sum of " + sum
|