login
A334122
a(n) is the sum of all primes <= n, mod n.
1
0, 0, 2, 1, 0, 4, 3, 1, 8, 7, 6, 4, 2, 13, 11, 9, 7, 4, 1, 17, 14, 11, 8, 4, 0, 22, 19, 16, 13, 9, 5, 0, 28, 24, 20, 16, 12, 7, 2, 37, 33, 28, 23, 17, 11, 5, 46, 40, 34, 28, 22, 16, 10, 3, 51, 45, 39, 33, 27, 20, 13, 5, 60, 53, 46, 39, 32, 24, 16, 8, 0, 63, 55
OFFSET
1,3
LINKS
FORMULA
a(n) = A034387(n) mod n.
EXAMPLE
a(7) = (2+3+5+7) mod 7 = 17 mod 7 = 3.
MAPLE
b:= proc(n) b(n):= `if`(n<2, 0, b(n-1)+`if`(isprime(n), n, 0)) end:
a:= n-> irem(b(n), n):
seq(a(n), n=1..80); # Alois P. Heinz, Apr 15 2020
MATHEMATICA
Mod[Accumulate[(# * Boole @ PrimeQ[#]) & /@ (r = Range[100])], r] (* Amiram Eldar, Apr 15 2020 *)
PROG
(Python) return (sum(i for i in range(n+1) if is_prime(i)) % n)
(PARI) a(n) = my(np=primepi(n)); vecsum(primes(np)) % n; \\ Michel Marcus, Apr 16 2020
CROSSREFS
KEYWORD
nonn,easy,look
AUTHOR
Christoph Schreier, Apr 15 2020
STATUS
approved