login
Sum of remainders of the n-th prime mod k, for k = 1,2,3,...,n.
3

%I #6 Feb 04 2021 00:04:37

%S 0,1,3,5,7,7,14,18,28,30,31,26,38,45,63,71,93,75,96,115,101,142,161,

%T 167,152,159,203,224,219,222,216,250,263,296,341,320,319,349,433,427,

%U 496,419,487,481,538,537,495,631,635,676,697,777,665,820,784,874,929,856

%N Sum of remainders of the n-th prime mod k, for k = 1,2,3,...,n.

%H Daniel Suteu, <a href="/A099726/b099726.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = n*p - A024916(p) + Sum_{k=n+1..p} k*floor(p/k), where p = prime(n). - _Daniel Suteu_, Feb 02 2021

%e 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.

%p umpf:=n->add(modp(floor(ithprime(n)),m),m=1..n); seq(umpf(k),k=1..120);

%o (PARI) a(n) = my(p=prime(n)); sum(k=1, n, p%k); \\ _Daniel Suteu_, Feb 02 2021

%o (PARI)

%o T(n) = n*(n+1)/2;

%o S(n) = my(s=sqrtint(n)); sum(k=1, s, T(n\k) + k*(n\k)) - s*T(s); \\ A024916

%o 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;

%o a(n) = my(p=prime(n)); n*p - S(p) + g(n+1, p); \\ _Daniel Suteu_, Feb 02 2021

%Y Cf. A000040, A004125.

%K easy,nonn

%O 1,3

%A Joseph Biberstine (jrbibers(AT)indiana.edu), Nov 07 2004

%E Definition corrected by _Daniel Suteu_, Feb 02 2021