A099726 Sum of remainders of the n-th prime mod k, for k = 1,2,3,...,n.
0, 1, 3, 5, 7, 7, 14, 18, 28, 30, 31, 26, 38, 45, 63, 71, 93, 75, 96, 115, 101, 142, 161, 167, 152, 159, 203, 224, 219, 222, 216, 250, 263, 296, 341, 320, 319, 349, 433, 427, 496, 419, 487, 481, 538, 537, 495, 631, 635, 676, 697, 777, 665, 820, 784, 874, 929, 856
Offset: 1
Examples
a(7)=14 because the 7th prime is 17 and its remainders modulo 1,2,3,4,5,6,7 are 0,1,2,1,2,5,3 respectively and 0+1+2+1+2+5+3=14.
Links
- Daniel Suteu, Table of n, a(n) for n = 1..10000
Programs
-
Maple
umpf:=n->add(modp(floor(ithprime(n)),m),m=1..n); seq(umpf(k),k=1..120);
-
Mathematica
Table[Total[Mod[Prime[p],Range[p]]],{p,Range[60]}] (* Harvey P. Dale, Feb 09 2025 *)
-
PARI
a(n) = my(p=prime(n)); sum(k=1, n, p%k); \\ Daniel Suteu, Feb 02 2021
-
PARI
T(n) = n*(n+1)/2; S(n) = my(s=sqrtint(n)); sum(k=1, s, T(n\k) + k*(n\k)) - s*T(s); \\ A024916 g(a,b) = my(s=0); while(a <= b, my(t=b\a); my(u=b\t); s += t*(T(u) - T(a-1)); a = u+1); s; a(n) = my(p=prime(n)); n*p - S(p) + g(n+1, p); \\ Daniel Suteu, Feb 02 2021
Formula
a(n) = n*p - A024916(p) + Sum_{k=n+1..p} k*floor(p/k), where p = prime(n). - Daniel Suteu, Feb 02 2021
Extensions
Definition corrected by Daniel Suteu, Feb 02 2021