OFFSET
1,1
COMMENTS
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..9661
Wikipedia, Agoh-Giuga conjecture
MATHEMATICA
a[n_] := Block[{k = n+1}, While[PrimeQ[k] || Mod[Sum[PowerMod[j, k-1, k], {j, n}], k] != n, k++]; k]; Array[a, 60] (* Giovanni Resta, Jul 26 2018 *)
PROG
(PARI) a(n) = forcomposite(k=n+1, , if (sum(j=1, n, Mod(j, k)^(k-1)) == n, return (k)); ); \\ Michel Marcus, Jul 26 2018
(Python)
from sympy import isprime
def g(n, p, q): # compute (-n + sum_{k=1, n} k^p) mod q
c = (-n) % q
for k in range(1, n+1):
c = (c+pow(k, p, q)) % q
return c
def A317357(n):
k = n+1
while isprime(k) or g(n, k-1, k):
k += 1
return k # Chai Wah Wu, Jul 31 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Jul 26 2018
EXTENSIONS
More terms from Giovanni Resta, Jul 26 2018
STATUS
approved