login
A317058
a(n) is the smallest composite k such that 1^(k-1) + 2^(k-1) + ... + n^(k-1) == n (mod k).
6
4, 341, 473, 4, 4, 133, 497, 4, 4, 15, 9, 4, 4, 143, 35, 4, 4, 51, 57, 4, 4, 77, 253, 4, 4, 65, 9, 4, 4, 115, 155, 4, 4, 187, 35, 4, 4, 9, 247, 4, 4, 287, 2051, 4, 4, 15, 33, 4, 4, 35, 85, 4, 4, 9, 9, 4, 4, 551, 1711, 4, 4, 713, 21, 4, 4, 55, 77, 4, 4, 35, 35, 4
OFFSET
1,1
COMMENTS
According to the Agoh-Giuga conjecture, a(n) <> n+1.
a(n) = 4 if and only if n == {0, 1} (mod 4).
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..9661 (n = 1..500 from Seiichi Manyama)
MATHEMATICA
a[n_] := Block[{k = 4}, While[PrimeQ[k] || Mod[Sum[PowerMod[j, k-1, k], {j, n}], k] != Mod[n, k], k++]; k]; Array[a, 72] (* Giovanni Resta, Jul 26 2018 *)
PROG
(PARI) a(n) = forcomposite(k=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 A317058(n):
k = 2
while isprime(k) or g(n, k-1, k):
k += 1
return k # Chai Wah Wu, Jul 30 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Jul 26 2018
EXTENSIONS
More terms from Giovanni Resta, Jul 26 2018
STATUS
approved