%I #21 Jan 29 2022 10:29:00
%S 2,3,23,67,227,10331
%N Prime numbers p such that K(p) = 0! + 1! + ... + (p-1)! == -2 (mod p).
%C 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.
%C No further terms < 6*10^6. - _Michael S. Branicky_, Jan 03 2022
%H Vladica Andrejić, Alin Bostan and Milos Tatarevic, <a href="https://doi.org/10.1016/j.ipl.2020.106078">Improved algorithms for left factorial residues</a>, Information Processing Letters, Vol. 167 (2021), Article ID 106078, 4 p.; <a href="https://arxiv.org/abs/1904.09196">arXiv preprint</a>, arXiv:1904.09196 [math.NT], 2019-2020.
%t q[p_] := PrimeQ[p] && Divisible[Sum[k!, {k, 0, p - 1}] + 2, p]; Select[Range[230], q] (* _Amiram Eldar_, Jan 03 2022 *)
%o (Python)
%o from sympy import isprime
%o def K(n):
%o ans, f = 0, 1
%o for i in range(1, n+1):
%o ans += f%n
%o f = (f*i)%n
%o return ans%n
%o def ok(n): return isprime(n) and (K(n) + 2)%n == 0
%o print([k for k in range(11000) if ok(k)]) # _Michael S. Branicky_, Jan 03 2022
%o (Python) # faster version for initial segment of sequence
%o from sympy import isprime
%o def afind(limit):
%o f = 1 # (p-1)!
%o s = 2 # sum(0! + 1! + ... + (p-1)!)
%o for p in range(2, limit+1):
%o if isprime(p) and s%p == p-2:
%o print(p, end=", ")
%o s += f*p
%o f *= p
%o afind(11000) # _Michael S. Branicky_, Jan 03 2022
%Y Cf. A003422, A100612.
%Y Subsequence of A236400.
%K nonn,more
%O 1,1
%A _Luis H. Gallardo_, Jan 03 2022
|