blob: d4a533439de556f6474747a7d13ce93ee679b24d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
|