cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-5 of 5 results.

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

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Comments

Row sums of A051778, A048158. Antidiagonal sums of A051127. - L. Edson Jeffery, Mar 03 2012
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]
Also the alternating row sums of A236112. - Omar E. Pol, Jan 26 2014
If n is prime then a(n) = a(n-1) + n - 2. - Omar E. Pol, Mar 19 2014
If n is a power of 2 greater than 1, then a(n) = a(n-1). - David Morales Marciel, Oct 21 2015
It appears that if n is an even perfect number, then a(n) = a(n-1) - 1. - Omar E. Pol, Oct 21 2015
Partial sums of A235796. - Omar E. Pol, Jun 26 2016
Aside from a(n) = a(n-1) for n = 2^m, the only values appearing more than once among the first 6*10^8 terms are those at n = 38184 +- 1, 458010 +- 1, 776112 +- 1, 65675408 +- 1, and 113393280 +- 2. - Trevor Cappallo, Jun 07 2021
The off-by-1 terms in the comment above are the terms of A068077. Proof: If a(n-1) = a(n+1), then (n-1)^2 - Sum_{k=1..n-1} sigma(k) = (n+1)^2 - Sum_{k=1..n+1} sigma(k) via the formula; rearranging terms gives sigma(n)+sigma(n+1)=4n. - Lewis Chen, Sep 24 2021

Examples

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

References

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

Crossrefs

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

Programs

  • GAP
    List([1..70],n->n^2-Sum([1..n],k->Sigma(k))); # Muniru A Asiru, Mar 28 2018
    
  • Haskell
    a004125 n = sum $ map (mod n) [1..n]
    -- Reinhard Zumkeller, Jan 28 2011
    
  • Magma
    [&+[n mod r: r in [1..n]]: n in [1..70]]; // Bruno Berselli, Jul 06 2014
    
  • Maple
    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
  • Mathematica
    Table[Sum[Mod[n,k],{k,2,n-1}],{n,70}] (* Harvey P. Dale, Nov 23 2011 *)
    Accumulate[Table[2n-1-DivisorSigma[1,n],{n,70}]] (* Harvey P. Dale, Jul 11 2014 *)
  • PARI
    A004125(n)=sum(k=2,n,n%k) \\ M. F. Hasler, Nov 22 2007
    
  • Python
    def a(n): return sum(n%k for k in range(1, n))
    print([a(n) for n in range(1, 63)]) # Michael S. Branicky, Jun 08 2021
    
  • Python
    from math import isqrt
    def A004125(n): return n**2+((s:=isqrt(n))**2*(s+1)-sum((q:=n//k)*((k<<1)+q+1) for k in range(1,s+1))>>1) # Chai Wah Wu, Oct 21 2023
    
  • SageMath
    def a(n): return sum(n.mod(k) for k in (1..n))
    print([a(n) for n in (1..62)])  # Peter Luschny, May 12 2025

Formula

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
a(n) = A008805(n-3) + A049798(n-1), for n > 2. - Carl Najafi, Jan 31 2013
a(n) = A000217(n-1) - A153485(n). - Omar E. Pol, Jan 28 2014
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
a(n) = Sum_{i=1..n} (n mod i). - Wesley Ivan Hurt, Sep 15 2017
From Ridouane Oudra, May 12 2025: (Start)
a(n) = A067439(n) + A072514(n).
a(n) = Sum_{d|n} d*A067439(n/d).
a(p) = A067439(p), for p prime.
a(p^k) = A072514(p^(k+1))/p, for p prime and k >= 0. (End)
a(n) = A111490(n) - n. - Peter Luschny, May 12 2025

Extensions

Edited by M. F. Hasler, Apr 18 2015

A008805 Triangular numbers repeated.

Original entry on oeis.org

1, 1, 3, 3, 6, 6, 10, 10, 15, 15, 21, 21, 28, 28, 36, 36, 45, 45, 55, 55, 66, 66, 78, 78, 91, 91, 105, 105, 120, 120, 136, 136, 153, 153, 171, 171, 190, 190, 210, 210, 231, 231, 253, 253, 276, 276, 300, 300, 325, 325, 351, 351, 378, 378, 406, 406, 435, 435
Offset: 0

Views

Author

Keywords

Comments

Number of choices for nonnegative integers x,y,z such that x and y are even and x + y + z = n.
Diagonal sums of A002260, when arranged as a number triangle. - Paul Barry, Feb 28 2003
a(n) = number of partitions of n+4 such that the differences between greatest and smallest parts are 2: a(n-4) = A097364(n,2) for n>3. - Reinhard Zumkeller, Aug 09 2004
For n >= i, i=4,5, a(n-i) is the number of incongruent two-color bracelets of n beads, i from them are black (cf. A005232, A032279), having a diameter of symmetry. - Vladimir Shevelev, May 03 2011
Prefixing A008805 by 0,0,0,0 gives the sequence c(0), c(1), ... defined by c(n)=number of (w,x,y) such that w = 2x+2y, where w,x,y are all in {1,...,n}; see A211422. - Clark Kimberling, Apr 15 2012
Partial sums of positive terms of A142150. - Reinhard Zumkeller, Jul 07 2012
The sum of the first parts of the nondecreasing partitions of n+2 into exactly two parts, n >= 0. - Wesley Ivan Hurt, Jun 08 2013
Number of the distinct symmetric pentagons in a regular n-gon, see illustration for some small n in links. - Kival Ngaokrajang, Jun 25 2013
a(n) is the number of nonnegative integer solutions to the equation x + y + z = n such that x + y <= z. For example, a(4) = 6 because we have 0+0+4 = 0+1+3 = 0+2+2 = 1+0+3 = 1+1+2 = 2+0+2. - Geoffrey Critzer, Jul 09 2013
a(n) is the number of distinct opening moves in n X n tic-tac-toe. - I. J. Kennedy, Sep 04 2013
a(n) is the number of symmetry-allowed, linearly-independent terms at n-th order in the series expansion of the T2 X t2 vibronic perturbation matrix, H(Q) (cf. Opalka & Domcke). - Bradley Klee, Jul 20 2015
a(n-1) also gives the number of D_4 (dihedral group of order 4) orbits of an n X n square grid with squares coming in either of two colors and only one square has one of the colors. - Wolfdieter Lang, Oct 03 2016
Also, this sequence is the third column in the triangle of the coefficients of the sum of two consecutive Fibonacci polynomials F(n+1, x) and F(n, x) (n>=0) in ascending powers of x. - Mohammad K. Azarian, Jul 18 2018
In an n-person symmetric matching pennies game (a zero-sum normal-form game) with n > 2 symmetric and indistinguishable players, each with two strategies (viz. heads or tails), a(n-3) is the number of distinct subsets of players that must play the same strategy to avoid incurring losses (single pure Nash equilibrium in the reduced game). The total number of distinct partitions is A000217(n-1). - Ambrosio Valencia-Romero, Apr 17 2022
a(n) is the number of connected bipartite graphs with n+1 edges and a stable set of cardinality 2. - Christian Barrientos, Jun 15 2022
a(n) is the number of 132-avoiding odd Grassmannian permutations of size n+2. - Juan B. Gil, Mar 10 2023
Consider a regular n-gon with all diagonals drawn. Define a "layer" to be the set of all regions sharing an edge with the exterior. Removing a layer creates another layer. Count the layers, removing them until none remain. The number of layers is a(n-2). See illustration. - Christopher Scussel, Nov 07 2023

Examples

			a(5) = 6, since (5) + 2 = 7 has three nondecreasing partitions with exactly 2 parts: (1,6),(2,5),(3,4). The sum of the first parts of these partitions = 1 + 2 + 3 = 6. - _Wesley Ivan Hurt_, Jun 08 2013
		

References

  • H. D. Brunk, An Introduction to Mathematical Statistics, Ginn, Boston, 1960; p. 360.

Crossrefs

Cf. A000217, A002260, A002620, A006918 (partial sums), A054252, A135276, A142150, A158920 (binomial trans.).

Programs

  • GAP
    List([0..60], n-> (2*n +3 +(-1)^n)*(2*n +7 +(-1)^n)/32); # G. C. Greubel, Sep 12 2019
    
  • Haskell
    import Data.List (transpose)
    a008805 = a000217 . (`div` 2) . (+ 1)
    a008805_list = drop 2 $ concat $ transpose [a000217_list, a000217_list]
    -- Reinhard Zumkeller, Feb 01 2013
    
  • Magma
    [(2*n+3+(-1)^n)*(2*n+7+(-1)^n)/32 : n in [0..50]]; // Wesley Ivan Hurt, Apr 22 2015
    
  • Maple
    A008805:=n->(2*n+3+(-1)^n)*(2*n+7+(-1)^n)/32: seq(A008805(n), n=0..50); # Wesley Ivan Hurt, Apr 22 2015
  • Mathematica
    CoefficientList[Series[1/(1-x^2)^2/(1-x), {x, 0, 50}], x]
    Table[Binomial[Floor[n/2] + 2, 2], {n, 0, 57}] (* Michael De Vlieger, Oct 03 2016 *)
  • PARI
    a(n)=(n\2+2)*(n\2+1)/2
    
  • Python
    def A008805(n): return (m:=(n>>1)+1)*(m+1)>>1 # Chai Wah Wu, Oct 20 2023
  • Sage
    [(2*n +3 +(-1)^n)*(2*n +7 +(-1)^n)/32 for n in (0..60)] # G. C. Greubel, Sep 12 2019
    

Formula

G.f.: 1/((1-x)*(1-x^2)^2) = 1/((1+x)^2*(1-x)^3).
E.g.f.: (exp(x)*(2*x^2 +12*x+ 11) - exp(-x)*(2*x -5))/16.
a(-n) = a(-5+n).
a(n) = binomial(floor(n/2)+2, 2). - Vladimir Shevelev, May 03 2011
From Paul Barry, May 31 2003: (Start)
a(n) = ((2*n +5)*(-1)^n + (2*n^2 +10*n +11))/16.
a(n) = Sum_{k=0..n} ((k+2)*(1+(-1)^k))/4. (End)
From Paul Barry, Apr 16 2005: (Start)
a(n) = Sum_{k=0..n} floor((k+2)/2)*(1-(-1)^(n+k-1))/2.
a(n) = Sum_{k=0..floor(n/2)} floor((n-2k+2)/2). (End)
A signed version is given by Sum_{k=0..n} (-1)^k*floor(k^2/4). - Paul Barry, Aug 19 2003
a(n) = A108299(n-2,n)*(-1)^floor((n+1)/2) for n>1. - Reinhard Zumkeller, Jun 01 2005
a(n) = A004125(n+3) - A049798(n+2). - Carl Najafi, Jan 31 2013
a(n) = Sum_{i=1..floor((n+2)/2)} i. - Wesley Ivan Hurt, Jun 08 2013
a(n) = (1/2)*floor((n+2)/2)*(floor((n+2)/2)+1). - Wesley Ivan Hurt, Jun 08 2013
From Wesley Ivan Hurt, Apr 22 2015: (Start)
a(n) = a(n-1) +2*a(n-2) -2*a(n-3) -a(n-4) +a(n-5).
a(n) = (2*n +3 +(-1)^n)*(2*n +7 +(-1)^n)/32. (End)
a(n-1) = A054252(n,1) = A054252(n^2-1), n >= 1. See a Oct 03 2016 comment above. - Wolfdieter Lang, Oct 03 2016
a(n) = A000217(A008619(n)). - Guenther Schrack, Sep 12 2018
From Ambrosio Valencia-Romero, Apr 17 2022: (Start)
a(n) = a(n-1) if n odd, a(n) = a(n-1) + (n+2)/2 if n is even, for n > 0, a(0) = 1.
a(n) = (n+1)*(n+3)/8 if n odd, a(n) = (n+2)*(n+4)/8 if n is even, for n >= 0.
a(n) = A002620(n+2) - a(n-1), for n > 0, a(0) = 1.
a(n) = A142150(n+2) + a(n-1), for n > 0, a(0) = 1.
a(n) = A000217(n+3)/2 - A135276(n+3)/2. (End)

A049800 Triangular array T, read by rows: T(n,k) = (n+1) mod floor((k+1)/2), k = 1..n and n >= 1.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 2, 2, 0, 0, 0, 1, 1, 2, 2, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 4, 4, 2, 2, 0
Offset: 1

Views

Author

Keywords

Examples

			Array T(n,k) (with rows n >= 1 and columns k >= 1) begins as follows:
  0;
  0, 0;
  0, 0, 0;
  0, 0, 1, 1;
  0, 0, 0, 0, 0;
  0, 0, 1, 1, 1, 1;
  0, 0, 0, 0, 2, 2, 0;
  0, 0, 1, 1, 0, 0, 1, 1;
  0, 0, 0, 0, 1, 1, 2, 2, 0;
  0, 0, 1, 1, 2, 2, 3, 3, 1, 1;
  0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0;
  ...
		

Crossrefs

One-half the row sums are in A049798.

Programs

  • GAP
    Flat(List([1..15], n-> List([1..n], k-> (n+1) mod Int((k+1)/2) ))); # G. C. Greubel, Dec 09 2019
  • Magma
    [ (n+1) mod Floor((k+1)/2): k in [1..n], n in [1..15]]; // G. C. Greubel, Dec 09 2019
    
  • Maple
    # To get the sequence:
    seq(seq((n+1) mod floor((k+1)/2), k = 1..n), n = 1..30);
    # To get the triangular array:
    for n from 1 to 30 do
        seq((n+1) mod floor((k+1)/2), k = 1..n);
    end do; # Petros Hadjicostas, Nov 20 2019
  • Mathematica
    Table[Mod[n+1, Floor[(k+1)/2]], {n,15}, {k,n}]//Flatten (* G. C. Greubel, Dec 09 2019 *)
  • PARI
    T(n,k) = lift(Mod(n+1,(k+1)\2));
    for(n=1, 15, for(k=1, n, print1(T(n,k), ", "))) \\ G. C. Greubel, Dec 09 2019
    
  • Sage
    [[ mod(n+1, floor((k+1)/2)) for k in (1..n)] for n in (1..15)] # G. C. Greubel, Dec 09 2019
    

Extensions

Name edited by Petros Hadjicostas, Nov 20 2019

A049799 a(n) = Sum_{k = 3..n} T(n,k), where the array T is A049801.

Original entry on oeis.org

0, 0, 0, 0, 2, 0, 3, 2, 9, 0, 8, 12, 12, 5, 18, 15, 29, 12, 18, 29, 48, 21, 26, 42, 54, 38, 63, 39, 65, 51, 69, 92, 87, 45, 77, 105, 129, 77, 114, 96, 134, 123, 111, 146, 189, 126, 149, 144, 180, 170, 219, 207, 209, 156, 198, 245
Offset: 3

Views

Author

Keywords

Crossrefs

Row sums of triangle A049801.

Programs

  • GAP
    List([3..60], n-> Sum([3..n], k-> n mod Int(k/3)) ); # G. C. Greubel, Dec 09 2019
  • Magma
    [ (&+[n mod Floor(k/2): k in [3..n]]): n in [3..60]]; // G. C. Greubel, Dec 09 2019
    
  • Maple
    seq(add(n mod floor(k/3), k = 3 .. n), n = 3..60); # Petros Hadjicostas, Nov 20 2019
  • Mathematica
    Table[Sum[Mod[n, Floor[k/3]], {k, 3, n}], {n, 3, 60}] (* G. C. Greubel, Dec 09 2019 *)
  • PARI
    vector(60, n, sum(k=3,n+2, (n+2)%(k\3)) ) \\ G. C. Greubel, Dec 09 2019
    
  • Sage
    [sum( n%floor(k/3)  for k in (3..n)) for n in (3..60)] # G. C. Greubel, Dec 09 2019
    

A049801 Triangular array T, read by rows: T(n,k) = n mod floor(k/3), k = 3..n and n >= 3.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 0, 0, 0, 3, 3, 3, 0
Offset: 3

Views

Author

Keywords

Examples

			Array T(n,k) (with rows n >= 3 and columns k >= 3) begins as follows:
  0;
  0, 0;
  0, 0, 0;
  0, 0, 0, 0;
  0, 0, 0, 1, 1;
  0, 0, 0, 0, 0, 0;
  0, 0, 0, 1, 1, 1, 0;
  0, 0, 0, 0, 0, 0, 1, 1;
  0, 0, 0, 1, 1, 1, 2, 2, 2;
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
  0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1;
  0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2;
  ...
		

Crossrefs

Row sums are in A049799.

Programs

  • GAP
    Flat(List([3..15], n-> List([3..n], k-> n mod Int(k/3) ))); # G. C. Greubel, Dec 09 2019
  • Magma
    [ n mod Floor(k/3): k in [3..n], n in [3..15]]; // G. C. Greubel, Dec 09 2019
    
  • Maple
    # To get the sequence:
    seq(seq(n mod floor(k/3), k = 3..n), n = 3..30);
    # To get the triangular array:
    for n from 3 to 30 do
        seq(n mod floor(k/3), k = 3..n);
    end do; # Petros Hadjicostas, Nov 20 2019
  • Mathematica
    Table[Mod[n, Floor[k/3]], {n,3,15}, {k,3,n}]//Flatten (* G. C. Greubel, Dec 09 2019 *)
  • PARI
    T(n,k) = lift(Mod(n, k\3)); \\ G. C. Greubel, Dec 09 2019
    
  • Sage
    [[ mod(n, floor(k/3)) for k in (3..n)] for n in (3..15)] # G. C. Greubel, Dec 09 2019
    

Extensions

Name edited by and more terms from Petros Hadjicostas, Nov 20 2019
Showing 1-5 of 5 results.