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.

A140757 Cumulative sums of A140756.

Original entry on oeis.org

1, 0, 2, 3, 1, 4, 3, 5, 2, 6, 7, 5, 8, 4, 9, 8, 10, 7, 11, 6, 12, 13, 11, 14, 10, 15, 9, 16, 15, 17, 14, 18, 13, 19, 12, 20, 21, 19, 22, 18, 23, 17, 24, 16, 25, 24, 26, 23, 27, 22, 28, 21, 29, 20, 30, 31, 29, 32, 28, 33, 27, 34, 26, 35, 25, 36, 35, 37, 34, 38, 33, 39, 32, 40, 31, 41
Offset: 1

Views

Author

Keywords

Comments

Each positive integer occurs exactly twice in this sequence, with 0 occurring only once. In particular, if A002620(n) < m < A002620(n+1), then m occurs in rows n-1 and n; and A002620(n) occurs in rows in rows n-1 (as T(n-1,n-1)) and n+1 (as T(n+1,n)).

Examples

			As a triangle:
  1;
  0,  2;
  3,  1,  4;
  3,  5,  2,  6;
  7,  5,  8,  4,  9;
  8, 10,  7, 11,  6, 12;
  ...
		

Crossrefs

Programs

  • Magma
    A140756:=[(-1)^(n+k)*k: k in [1..n], n in [1..40]];
    A140757:= func< n | (&+[A140756[j]: j in [1..n]]) >;
    [A140757(n): n in [1..100]]; // G. C. Greubel, Oct 21 2023
    
  • Mathematica
    A140756[n_]:= With[{t=Floor[(-1+Sqrt[8*n-7])/2]}, (-1)^(Binomial[t+2, 2] -n)*(n -Binomial[t+1,2])];
    A140757[n_]:= Sum[A140756[j], {j,n}];
    Table[A140757[n], {n,100}] (* G. C. Greubel, Oct 21 2023 *)
  • PARI
    T(n,k)=if((n-k)%2==0, ((n+1)^2\4)-((n-k)\2), ((n-1)^2\4)+((n-k)\2) ) \\ Paul D. Hanna
    
  • Python
    from math import comb, isqrt
    def A140757(n): return ((a-1)**2>>2)+(c>>1) if (c:=(a:=(m:=isqrt(k:=n<<1))+(k>m*(m+1)))-(b:=n-comb(a,2)))&1 else ((a+1)**2>>2)-(c>>1) # Chai Wah Wu, Jun 09 2025
  • SageMath
    A140756=flatten([[(-1)^(n+k)*k for k in range(1,n+1)] for n in range(1,41)])
    def A140757(n): return sum(A140756[j] for j in range(n))
    [A140757(n) for n in range(1,101)] # G. C. Greubel, Oct 21 2023
    

Formula

T(n,k) = floor((n+(-1)^{n-k})^2/4) - (-1)^{n-k}*floor((n-k)/2), as a triangle, with n >= 1, 1 <= k <= n.