OFFSET
2,2
COMMENTS
a(n) = 0 if and only if prime(n) is in both A007540 and A197632, i.e., prime(n) is simultaneously a Wilson prime and a Lerch prime.
For n > 2, a(n) = 0 if and only if A027641(3*p-3) / A027642(3*p-3)-1 + 1/p == 0 (mod p^2), where p = prime(n) (cf. Dobson, 2016, theorem 2).
René Gy (see links) has shown that a number is simultaneously a Lerch prime and a Wilson prime if and only if it satisfies the congruence (p - 1)! + 1 == 0 (mod p^3). - John Blythe Dobson, Feb 23 2018
LINKS
John Blythe Dobson, A Characterization of Wilson-Lerch Primes, Integers, 16 (2016), A51.
René Gy, Generalized Lerch Primes, Integers 18 (2018), A10.
Jonathan Sondow, Lerch Quotients, Lerch Primes, Fermat-Wilson Quotients, and the Wieferich-non-Wilson Primes 2, 3, 14771, in Proceedings of CANT 2011, arXiv:1110.3113 [math.NT], 2011-2012.
MATHEMATICA
a[n_] := Module[{p = Prime[n]}, Mod[((p-1)!+1)/p, p] + Mod[(Sum[(k^(p-1)-1)/p, {k, 1, p-1}] - ((p-1)!+1)/p)/p, p]];
Table[a[n], {n, 2, 60}] (* Jean-François Alcover, Feb 15 2019 *)
PROG
(PARI) a002068(n) = my(p=prime(n)); ((p-1)!+1)/p % p
a197631(n) = my(p=prime(n), m=p-1); sum(k=1, m, k^m, -p-m!)/p^2 % p
a(n) = a002068(n) + a197631(n)
CROSSREFS
KEYWORD
nonn
AUTHOR
Felix Fröhlich, Aug 07 2016
STATUS
approved