18 lines
470 B
Text
18 lines
470 B
Text
local int = require "int"
|
|
local fmt = require "fmt"
|
|
|
|
for i = 1, 10 do
|
|
fmt.print("%2d -> %s", i, fmt.swrite(int.divisors(i, true)))
|
|
end
|
|
|
|
print("\nThe number in the range {1, 20,000} with the most proper divisors is:")
|
|
local number = 1
|
|
local max_divs = 0
|
|
for i = 2, 20_000 do
|
|
local [divs, _] = int.divstat(i, true)
|
|
if divs > max_divs then
|
|
number = i
|
|
max_divs = divs
|
|
end
|
|
end
|
|
print($"{fmt.int(number)} which has {max_divs} proper divisors.")
|