A350523 Prime numbers p such that K(p) = 0! + 1! + ... + (p-1)! == -2 (mod p).
2, 3, 23, 67, 227, 10331
Offset: 1
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.
Programs
-
Mathematica
q[p_] := PrimeQ[p] && Divisible[Sum[k!, {k, 0, p - 1}] + 2, p]; Select[Range[230], q] (* Amiram Eldar, Jan 03 2022 *)
-
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
Comments