OFFSET
2,1
MATHEMATICA
Rest@ Nest[Function[a, Append[a, Block[{k = a[[-1]]}, While[! AllTrue[Table[Or[# == 1, # == m - 1] &@ Mod[k, m], {m, Length@ a + 1}], # &], k++]; k]]], {2}, 16] (* Michael De Vlieger, Aug 02 2018 *)
PROG
(PARI)
ok(n, m)={for(i=2, n, my(r=m%i); if(r<>1&&r<>i-1, return(0))); 1}
a(n)={my(m=oo, p=primes(primepi(n))); p=vector(#p, i, p[i]^logint(n, p[i]));
for(k=0, 2^#p-1, my(t=2+lift(-2+chinese(vector(#p, i, Mod(if(bittest(k, i-1), -1, 1), p[i]))))); if(t<m && ok(n, t), m=t)); m} \\ Andrew Howroyd, Aug 02 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Kevin D. Woerner, Aug 02 2018
EXTENSIONS
a(21)-a(32) from Andrew Howroyd, Aug 02 2018
STATUS
approved