OFFSET
0,4
LINKS
Sean A. Irvine, Table of n, a(n) for n = 0..136
MATHEMATICA
fk[n_]:=Module[{k=n+1}, If[EvenQ[k], k++]; If[IntegerQ[Log[2, n]], k=0, While[ Mod[ n^k+n, k]!=0, k+=2]]; k]; Array[fk, 60, 0] (* Harvey P. Dale, Mar 12 2019 *)
PROG
(PARI) isp2(n) = (n==1) || (n==2) || (isprimepower(n, &p) && (p==2));
a(n) = {if (isp2(n), return (0)); my(k = if (n%2, n+2, n+1)); while(lift(Mod(n, k)^k + Mod(n, k)), k+=2); k; } \\ Michel Marcus, Dec 19 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
Missing a(0)=1, a(1)=0 inserted and a(5) corrected by Sean A. Irvine, Dec 19 2018
STATUS
approved