This site is supported by donations to The OEIS Foundation. Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A004125 Sum of remainders of n mod k, for k = 1, 2, 3, ..., n. (Formerly M3213) 76

%I M3213

%S 0,0,1,1,4,3,8,8,12,13,22,17,28,31,36,36,51,47,64,61,70,77,98,85,103,

%T 112,125,124,151,138,167,167,184,197,218,198,233,248,269,258,297,284,

%U 325,328,339,358,403,374,414,420,449,454,505,492,529,520,553,578,635,586,645,672

%N Sum of remainders of n mod k, for k = 1, 2, 3, ..., n.

%C Row sums of A051778, A048158. Antidiagonal sums of A051127. - _L. Edson Jeffery_, Mar 03 2012

%C Let u_m(n) = Sum_{k=1..n} (n^m mod k^m) with m integer. As n-->+oo, u_m(n) ~ (n^(m+1))*(1-(1/(m+1))*Zeta(1+1/m)). Proof: using Riemann sums, we have u_m(n) ~ (n^(m+1))*int(((1/x)[nonascii character here])*(1-floor(x^m)/(x^m)),x=1..+oo) and the result follows. - _Yalcin Aktar_, Jul 30 2008 [x is the real variable of integration. The nonascii character (which was illegible in the original message) is probably some form of multiplication sign. I suggest that we leave it the way it is for now. - _N. J. A. Sloane_, Dec 07 2014]

%C Also the alternating row sums of A236112. - _Omar E. Pol_, Jan 26 2014

%C If n is prime then a(n) = a(n-1) + n - 2. - _Omar E. Pol_, Mar 19 2014

%C If n is a power of 2 greater than 1 then a(n) = a(n-1). - _David Morales Marciel_, Oct 21 2015

%C It appears that if n is a even perfect number then a(n) = a(n-1) - 1. - _Omar E. Pol_, Oct 21 2015

%C Partial sums of A235796. - _Omar E. Pol_, Jun 26 2016

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H T. D. Noe, <a href="/A004125/b004125.txt">Table of n, a(n) for n = 1..1000</a>

%H Jeffrey Shallit, <a href="http://www.jstor.org/stable/2321999">Problem E2817</a>, Amer. Math. Monthly, vol. 87, p 137, 1980.

%F a(n) = n^2 - Sum_{k=1..n} sigma(k) = A000290(n) - A024916(n), hence asymptotically a(n) = n^2*(1-Pi^2/12) + O(n*log(n)^(2/3)). - _Benoit Cloitre_, Apr 28 2002. Asymptotics corrected/improved by _Charles R Greathouse IV_, Feb 22 2015

%F a(n) = A008805(n-3) + A049798(n-1), for n > 2. - _Carl Najafi_, Jan 31 2013

%F a(n) = A000217(n-1) - A153485(n). - _Omar E. Pol_, Jan 28 2014

%F G.f.: x^2/(1-x)^3 - (1-x)^(-1) * Sum_{k>=1} k*x^(2*k)/(1-x^k). - _Robert Israel_, Aug 13 2015

%F a(n) = Sum_{i=1..n} (n mod i). - _Wesley Ivan Hurt_, Sep 15 2017

%e a(5) = 4. The remainder when 5 is divided by 2,3,4 respectively is 1,2,1 and their sum = 4.

%p A004125 := n -> add( modp(n,k), k=2..n); /* much faster and unambiguous; "a mod b" may be mods(a,b) */ # _M. F. Hasler_, Nov 22 2007

%t Table[Sum[Mod[n,k],{k,2,n-1}],{n,70}] (* _Harvey P. Dale_, Nov 23 2011 *)

%t Accumulate[Table[2n-1-DivisorSigma[1,n],{n,70}]] (* _Harvey P. Dale_, Jul 11 2014 *)

%o (PARI) A004125(n)=sum(k=2,n,n%k) \\ _M. F. Hasler_, Nov 22 2007

%o (Visual Basic in Excel)

%o Sub SumMod()

%o X = 1

%o Do While X <= 200

%o Y = 2

%o Z = 0

%o Cells(X, 1).Value = X

%o Do While Y <= X

%o Z = Z + (X Mod Y)

%o Y = Y + 1

%o Loop

%o Cells(X, 2).Value = Z

%o X = X + 1

%o Loop

%o End Sub ' Kevin Irwin (kevin.irwin(AT)aya.yale.edu), Feb 14 2010

%o a004125 n = sum \$ map (mod n) [1..n]

%o -- _Reinhard Zumkeller_, Jan 28 2011.

%o (MAGMA) [&+[n mod r: r in [1..n]]: n in [1..70]]; // _Bruno Berselli_, Jul 06 2014

%o (GAP) List([1..70],n->n^2-Sum([1..n],k->Sigma(k))); # _Muniru A Asiru_, Mar 28 2018

%Y Cf. A000290, A006218, A023196, A048158, A050482, A051778, A120444 (first differences).

%K nonn,easy,nice

%O 1,5

%A _N. J. A. Sloane_, _Jeffrey Shallit_

%E Edited by _M. F. Hasler_, Apr 18 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified November 14 20:15 EST 2019. Contains 329130 sequences. (Running on oeis4.)