login
A350523
Prime numbers p such that K(p) = 0! + 1! + ... + (p-1)! == -2 (mod p).
0
2, 3, 23, 67, 227, 10331
OFFSET
1,1
COMMENTS
The Kurepa Conjecture says that K(p) is nonzero in F_p, the finite field with p elements. Primes for which K(p) takes some fixed nonzero value in F_p might have some interest.
No further terms < 6*10^6. - Michael S. Branicky, Jan 03 2022
LINKS
Vladica Andrejić, Alin Bostan and Milos Tatarevic, Improved algorithms for left factorial residues, Information Processing Letters, Vol. 167 (2021), Article ID 106078, 4 p.; arXiv preprint, arXiv:1904.09196 [math.NT], 2019-2020.
MATHEMATICA
q[p_] := PrimeQ[p] && Divisible[Sum[k!, {k, 0, p - 1}] + 2, p]; Select[Range[230], q] (* Amiram Eldar, Jan 03 2022 *)
PROG
(Python)
from sympy import isprime
def K(n):
ans, f = 0, 1
for i in range(1, n+1):
ans += f%n
f = (f*i)%n
return ans%n
def ok(n): return isprime(n) and (K(n) + 2)%n == 0
print([k for k in range(11000) if ok(k)]) # Michael S. Branicky, Jan 03 2022
(Python) # faster version for initial segment of sequence
from sympy import isprime
def afind(limit):
f = 1 # (p-1)!
s = 2 # sum(0! + 1! + ... + (p-1)!)
for p in range(2, limit+1):
if isprime(p) and s%p == p-2:
print(p, end=", ")
s += f*p
f *= p
afind(11000) # Michael S. Branicky, Jan 03 2022
CROSSREFS
Subsequence of A236400.
Sequence in context: A143853 A195241 A090180 * A262730 A260127 A009130
KEYWORD
nonn,more
AUTHOR
Luis H. Gallardo, Jan 03 2022
STATUS
approved