Add --cache option to factors script

This commit is contained in:
Talia 2020-08-27 14:45:03 +02:00
parent 4cc5d0ece9
commit cfe5f4fa77

View file

@ -7,10 +7,19 @@ local arrr = require 'arrr'
local parser = arrr {
{ "Enable batch factorization", "--batch", "-b" };
{ "Initialize prime table up to the Nth prime", "--initialize", "-n", "n", tonumber };
{ "Cache file", "--cache", "-c", 1, io.open };
}
local options = parser {...}
if options.cache then
local i = 1
for line in options.cache:lines() do
primes[i] = tonumber(line)
i = i + 1
end
end
if options.initialize then
for i=1, options.initialize do
local _ = primes[i]