A162733 Sum of remainders of the n-th composite mod k, for k=1,2,3,...,n.
0, 0, 2, 2, 3, 2, 10, 15, 15, 19, 25, 34, 41, 40, 58, 67, 80, 79, 83, 101, 118, 131, 152, 132, 170, 191, 180, 193, 223, 234, 253, 254, 294, 300, 329, 334, 356, 393, 384, 417, 442, 433, 501, 522, 522, 567, 554, 609, 650, 645, 642, 725, 750, 761, 818, 805, 833, 873
Offset: 1
Keywords
Examples
a(7)=10 because the 7th composite is 14 and its remainders modulo 1, 2, 3, 4, 5, 6, 7 are 0, 0, 2, 2, 4, 2, 0 respectively and 0 + 0 + 2 + 2 + 4 + 2 + 0 = 10.
Programs
-
Maple
A002808 := proc(n) local a; if n = 1 then 4; else for a from procname(n-1)+1 do if not isprime(a) then RETURN(a) ; end if; end do; end if; end proc: A162733 := proc(n) local c; c := A002808(n) ; add(c mod k, k=1..n) ; end: seq(A162733(n),n=1..80) ; # R. J. Mathar, Aug 01 2009
-
Mathematica
composite[n_] := FixedPoint[n + PrimePi[#] + 1 &, n + PrimePi[n] + 1]; a[n_] := Total[Mod[composite[n], #]& /@ Range[n]]; Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Jul 23 2024 *)
-
PARI
n=3;for(k=1,100,n++;n+=isprime(n);print1(sum(i=1,k,n%i)",")) \\ Franklin T. Adams-Watters, Aug 06 2009
Extensions
Corrected and extended by R. J. Mathar and Franklin T. Adams-Watters, Aug 01 2009