diff options
Diffstat (limited to '21.lua')
-rw-r--r-- | 21.lua | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -0,0 +1,24 @@ +function d(n) + if n < 2 then return 0 end + local ret = 1 + local test = 2 + local limit = math.sqrt(n) + while test < limit do + if n % test == 0 then + ret = ret + test + n / test + end + test = test + 1 + end + if limit == math.floor(limit) then ret = ret + limit end + return ret +end + +local sum = 0 +for i = 1, 9999 do + local di = d(i) + if d(di) == i and i ~= di then + print(i .. ": " .. di) + sum = sum + i + end +end +print(sum) |