login
a(n) is the smallest composite k > n such that 1^(k-1) + 2^(k-1) + ... + n^(k-1) == n (mod k).
5

%I #34 Aug 15 2018 22:36:08

%S 4,341,473,6,10,133,497,14,12,15,15,16,18,143,35,20,32,51,57,38,28,77,

%T 253,36,30,65,39,36,58,115,155,62,36,187,119,40,74,57,247,52,80,287,

%U 2051,86,55,69,69,94,54,175,85,65,65,159,69,70,64,551,1711,72

%N a(n) is the smallest composite k > n such that 1^(k-1) + 2^(k-1) + ... + n^(k-1) == n (mod k).

%C According to the Agoh-Giuga conjecture, a(n) > n+1.

%C a(n) > A151800(n) for all n < 33.

%C a(n) <= A271221(n) for n > 1.

%H Chai Wah Wu, <a href="/A317357/b317357.txt">Table of n, a(n) for n = 1..9661</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Agoh%E2%80%93Giuga_conjecture">Agoh-Giuga conjecture</a>

%t 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 *)

%o (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

%o (Python)

%o from sympy import isprime

%o def g(n,p,q): # compute (-n + sum_{k=1,n} k^p) mod q

%o c = (-n) % q

%o for k in range(1,n+1):

%o c = (c+pow(k,p,q)) % q

%o return c

%o def A317357(n):

%o k = n+1

%o while isprime(k) or g(n,k-1,k):

%o k += 1

%o return k # _Chai Wah Wu_, Jul 31 2018

%Y Cf. A151800, A271221, A317058, A317358.

%K nonn

%O 1,1

%A _Thomas Ordowski_, Jul 26 2018

%E More terms from _Giovanni Resta_, Jul 26 2018