login
This site is supported by donations to The OEIS Foundation.
Logo

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)
36
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, 112, 125, 124, 151, 138, 167, 167, 184, 197, 218, 198, 233, 248, 269, 258, 297, 284, 325, 328, 339, 358, 403, 374, 414, 420, 449, 454, 505, 492, 529, 520, 553, 578, 635, 586, 645, 672 (list; graph; refs; listen; history; internal format)
OFFSET

1,5

COMMENTS

Let u_m(n)=sum(n^m mod k^m, k=1..n) 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 (aktaryalcin(AT)msn.com), Jul 30 2008

REFERENCES

Problem E2817, Amer. Math. Monthly, vol. 87 p 137 1980.

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

LINKS

T. D. Noe, Table of n, a(n) for n=1..1000

FORMULA

David W. Wilson observes that a(n) is (1-pi^2/12)n^2 + O(n). The O(n) appears to be about -.322 n.

a(n)=n^2-A024916(n), hence asymptotically a(n)=n^2*(1-Pi^2/12)+O(n*Log(n)) - Benoit Cloitre (benoit7848c(AT)orange.fr), Apr 28 2002

a(n) = n^2 - sum_{k=1..n} sigma(k) (from problem E2817), a(n+1) = a(n) + 2n+1 - sigma(n+1). - T. D. Noe, Oct 06 2006

a(n)=Sum{k=1..n}{[(n-k+1) mod k]} [From Paolo P. Lava (paoloplava(AT)gmail.com), Jan 12 2009]

EXAMPLE

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

MAPLE

A004125 := n -> add( pmod(n, k), k=2..n); /* much faster and unambiguous; "a mod b" may be mods(a, b) */ - M. F. Hasler (Maximilian.Hasler(AT)gmail.com), Nov 22 2007

MATHEMATICA

Table[Sum[Mod[n, k], {k, 2, n-1}], {n, 70}] (* From Harvey P. Dale, Nov 23 2011 *)

PROG

(PARI) A004125(n)=sum(k=2, n, n%k) - M. F. Hasler (Maximilian.Hasler(AT)gmail.com), Nov 22 2007

Contribution from Kevin Irwin (kevin.irwin(AT)aya.yale.edu), Feb 14 2010: (Start)

(Other) Visual Basic in Excel

Sub SumMod()

X = 1

Y = 2

Z = 0

Do While X <= 200

Cells(X, 1).Value = X

Do While Y <= X

Z = Z + (X Mod Y)

Y = Y + 1

Loop

Cells(X, 2).Value = Z

X = X + 1

Y = 2

Z = 0

Loop

End Sub (End)

(Haskell)

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

-- Reinhard Zumkeller, Jan 28 2011.

CROSSREFS

Cf. A006218, A050482, A023196.

Sequence in context: A134390 A021699 A131416 * A137924 A171527 A198576

Adjacent sequences:  A004122 A004123 A004124 * A004126 A004127 A004128

KEYWORD

nonn,easy,nice

AUTHOR

N. J. A. Sloane (njas(AT)research.att.com), Jeffrey Shallit

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
Recent Additions | More pages | Superseeker | Maintained by The OEIS Foundation Inc.

Content is available under The OEIS End-User License Agreement .

Last modified February 17 06:27 EST 2012. Contains 205998 sequences.