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

16 lines
561 B
Text

require "bignum"
local int = require "int"
local fmt = require "fmt"
mpz.init()
local limit = 16_000_000 -- more than enought to find first million primes
local primes = int.primes(limit - 1)
primes:insert(1, 1)
print("The first ten primorial numbers are:")
for i = 0, 9 do print($"{i}: {mpz.primorial(primes[i + 1])}") end
print("\nThe following primorials have the lengths shown:")
mpz.convert(false) -- return strings rather than convert to bigints
for {1e1, 1e2, 1e3, 1e4, 1e5, 1e6} as i do
fmt.print("%7d: %d", i, #mpz.primorial(primes[i + 1]))
end