OFFSET
1,1
MATHEMATICA
f[1] = 341; f[2] = 1105; f[3] = 1729; f[n_] := f[n] = Block[{k = f[n -1], lp = Prime@ Range[2, n -1], p = Prime@ n}, While[ PrimeQ@ k || PowerMod[2, k -1, k] != 1 || PowerMod[p, k -1, k] != 1 || Union[ PowerMod[lp, k -1, k]] != {1}, k += 2]; k]; Union[ Table[ f@n, {n, 1012}]]
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert G. Wilson v, Oct 08 2021
STATUS
approved