%I #48 Apr 17 2024 02:20:39
%S 0,2,7,18,43,73,113,159,203,334,496,706,863,874,1097,1124,1560,2033,
%T 2073,2409,2462,3336,3345,3634,3958,4657,5198,5284,5186,6096,7801,
%U 8594,9270,9167,10659,10578,12375,12227,13221,13769,15958,16458,18820,17919,18722
%N a(n) = A086330(prime(n)).
%C The sequence sometimes decreases, as for example at a(29) = 5186 < 5284 = a(28).
%e For n = 3, a(n) = A086330(prime(3)) = A086330(5) = (2! mod 5) + (3! mod 5) + (4! mod 5) = 2 + 1 + 4 = 7.
%o (Python)
%o from sympy import isprime
%o l = []
%o for i in range(2,185):
%o if isprime(i):
%o sum = 0
%o reminder = 1
%o for j in range(2, i):
%o reminder = (reminder * j) % i
%o sum += reminder
%o l.append(sum)
%o print(l)
%o (Python)
%o from sympy import prime
%o def A371035(n):
%o a, c, p = 0, 1, prime(n)
%o for m in range(2,p):
%o c = c*m%p
%o a += c
%o return a # _Chai Wah Wu_, Apr 16 2024
%o (PARI) a(n) = my(p=prime(n)); sum(m=2, p, m! % p); \\ _Michel Marcus_, Apr 11 2024
%Y Cf. A086330, A000040.
%K easy,nonn
%O 1,2
%A _Alexandre Herrera_, Apr 10 2024