Perfect numbers: Difference between revisions
→{{header|Ruby}}: speed u p by using Integer.sqrt
(Updated to work with Nim 1.4. Changed indentation to conform to guidelines. Corrected the algorithm which computed an incorrect sum for square numbers.) |
(→{{header|Ruby}}: speed u p by using Integer.sqrt) |
||
Line 3,270:
<lang ruby>def perf(n)
divisors = []
for i in 1..
divisors << i << n/i if n % i == 0
end
|