RosettaCodeData/Task/Count-in-factors/Pluto/count-in-factors.pluto
2026-04-30 12:34:36 -04:00

17 lines
345 B
Text

local function factorize( n )
if n == 1 then return {1} end
local k, res = 2, {}
while n > 1 do
while n % k == 0 do
res[#res+1] = k
n /= k
end
k += 1
end
return res
end
for i = 1, 22 do
print( $'{string.format( "%2d", i )}: {table.concat( factorize( i ), " * " )}' )
end