Perfect numbers: Difference between revisions

(→‎Modules: The ntheory module has sped up a lot; reflect new speeds and show new is_mersenne_prime.)
Line 1,101:
<lang nim>import math
 
proc isperfectisPerfect(n: int): bool =
let max: int = (sqrt(n.toFloat)).toInt
var sum: int = 1
for i in 2 ..max <(n.toFloat.sqrt+1).toInt:
if n mod i == 0:
letsum q:+= int(i =+ n div i)
sum += (i + q)
return (n == sum)
 
for i in 2..10_000:
if isperfectisPerfect(i):
echo(i)</lang>
 
Anonymous user