RosettaCodeData/Task/Amicable-pairs/Pluto/amicable-pairs.pluto
2026-04-30 12:34:36 -04:00

14 lines
356 B
Text

local int = require "int"
local fmt = require "fmt"
require "table2"
local max <const> = 19_999
local a = table.create(max)
for i = 2, max do a[i] = int.divisors(i, true):sum() end
print("The amicable pairs below 20,000 are:")
for n = 2, max do
local m = a[n]
if n < m < max and n == a[m] then
fmt.print(" %5d and %5d", n, m)
end
end