A385301 a(n) = Sum_{k=0..p-1} 1/k! mod p where p is prime(n) and 1/k! is the inverse of k! modulo p.
0, 1, 0, 3, 6, 0, 8, 4, 4, 9, 21, 0, 39, 37, 40, 32, 26, 12, 61, 6, 57, 74, 21, 41, 39, 60, 86, 64, 4, 27, 55, 2, 63, 113, 29, 42, 150, 97, 33, 84, 100, 120, 184, 72, 1, 134, 100, 78, 145, 8, 199, 98, 65, 25, 104, 95, 153, 207, 90, 132, 67, 132, 301, 251, 293, 185, 168, 176, 120, 297
Offset: 1
Keywords
Examples
a(1) = Sum_(k=0..2 - 1) (k!)^(2 - 2) mod 2 = 0.
Links
- Robert Israel, Table of n, a(n) for n = 1..2585
Programs
-
Maple
f:= proc(n) local p,k; p:= ithprime(n); add(1/k!, k=1..p-1) mod p end proc: map(f, [$1..100]); # Robert Israel, Jul 01 2025
-
Mathematica
a[n_] := Module[{p = Prime[n]}, Mod[Sum[PowerMod[k!, p-2, p], {k, 0, p-1}], p]]; a[1] = 0; Array[a, 100] (* Amiram Eldar, Jun 26 2025 *)
-
PARI
a(n) = sum(k=0, prime(n) - 1, (k!)^(prime(n) - 2)) % prime(n); \\ Michel Marcus, Jun 25 2025
-
Python
from sympy import prime def a(n): p = prime(n) s = invfact = 1 for i in range(1, p): invfact = (invfact * pow(i, -1, p)) % p s += invfact return s % p # David Radcliffe, Jun 25 2025
Formula
a(n) = Sum_{k=0..prime(n) - 1} (k!)^(prime(n) - 2) mod prime(n) where prime(n) is the n-th prime.
a(n) = A153229(p) mod p, where p = prime(n). - David Radcliffe, Jun 26 2025
Extensions
More terms from Michel Marcus, Jun 25 2025