RosettaCodeData/Task/Gapful-numbers/Pluto/gapful-numbers.pluto
2026-04-30 12:34:36 -04:00

24 lines
622 B
Text

local fmt = require "fmt"
local starts = {1e2, 1e6, 1e7, 1e9, 7123}
local counts = {30, 15, 15, 10, 25}
for i = 1, #starts do
local count = 0
local j = math.round(starts[i])
local pow = 100
while true do
if j < pow * 10 then break end
pow *= 10
end
print($"First {counts[i]} gapful numbers starting at {fmt.int(starts[i])}")
while count < counts[i] do
local fl = (j // pow) *10 + (j % 10)
if j % fl == 0 then
io.write($"{j} ")
count += 1
end
j += 1
if j >= 10 * pow then pow *= 10 end
end
print("\n")
end