32 lines
547 B
Text
32 lines
547 B
Text
found = 0
|
|
curr = 3
|
|
|
|
while found < 20
|
|
sum = Totient(curr)
|
|
toti = sum
|
|
while toti <> 1
|
|
toti = Totient(toti)
|
|
sum += toti
|
|
end while
|
|
if sum = curr then
|
|
print sum
|
|
found += 1
|
|
end if
|
|
curr += 1
|
|
end while
|
|
end
|
|
|
|
function GCD(n, d)
|
|
if n = 0 then return d
|
|
if d = 0 then return n
|
|
if n > d then return GCD(d, (n mod d))
|
|
return GCD(n, (d mod n))
|
|
end function
|
|
|
|
function Totient(n)
|
|
phi = 0
|
|
for m = 1 to n
|
|
if GCD(m, n) = 1 then phi += 1
|
|
next m
|
|
return phi
|
|
end function
|