RosettaCodeData/Task/Perfect-totient-numbers/Pluto/perfect-totient-numbers.pluto
2026-04-30 12:34:36 -04:00

16 lines
334 B
Text

local int = require "int"
local perfect = {}
local n = 1
while #perfect < 20 do
local tot = n
local sum = 0
while tot != 1 do
tot = int.totient(tot)
sum += tot
end
if sum == n then perfect:insert(n) end
n += 2
end
print("The first 20 perfect totient numbers are:")
print(perfect:concat(", "))