20 lines
603 B
Text
20 lines
603 B
Text
do -- find some factorial primes - primes that are f - 1 or f + 1 for some factorial f
|
|
|
|
local fmt = require( "fmt" ) -- RC Pluto formatting library
|
|
local int = require( "int" ) -- RC Pluto integer library, inc. prime utilities
|
|
|
|
local f, fpCount, n = 1, 0, 0
|
|
while fpCount < 10 do
|
|
n += 1
|
|
f *= n
|
|
local fpOp = "-"
|
|
for fp = f - 1, f + 1, 2 do
|
|
if int.isprime( fp ) then
|
|
fpCount += 1
|
|
fmt.write( "%2d:%4d! %s 1 = %d\n", fpCount, n, fpOp, fp )
|
|
end
|
|
fpOp = "+"
|
|
end
|
|
end
|
|
|
|
end
|