A002262 Triangle read by rows: T(n,k) = k, 0 <= k <= n, in which row n lists the first n+1 nonnegative integers.
0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
Offset: 0
Examples
From _Daniel Forgues_, Apr 27 2011: (Start) Examples of set-theoretic representation of ordinal numbers: 0: {} 1: {0} = {{}} 2: {0, 1} = {0, {0}} = {{}, {{}}} 3: {0, 1, 2} = {{}, {0}, {0, 1}} = ... = {{}, {{}}, {{}, {{}}}} (End) From _Omar E. Pol_, Jul 15 2012: (Start) 0; 0, 1; 0, 1, 2; 0, 1, 2, 3; 0, 1, 2, 3, 4; 0, 1, 2, 3, 4, 5; 0, 1, 2, 3, 4, 5, 6; 0, 1, 2, 3, 4, 5, 6, 7; 0, 1, 2, 3, 4, 5, 6, 7, 8; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10; (End)
Links
- Charles R Greathouse IV, Rows n = 0..100, flattened
- Boris Putievskiy, Transformations [Of] Integer Sequences And Pairing Functions, arXiv preprint arXiv:1212.2732 [math.CO], 2012.
- Michael Somos, Sequences used for indexing triangular or square arrays
Crossrefs
Programs
-
Haskell
a002262 n k = a002262_tabl !! n !! k a002262_row n = a002262_tabl !! n a002262_tabl = map (enumFromTo 0) [0..] a002262_list = concat a002262_tabl -- Reinhard Zumkeller, Aug 05 2015, Jul 13 2012, Mar 07 2011
-
Maple
seq(seq(i,i=0..n),n=0..14); # Peter Luschny, Sep 22 2011 A002262 := n -> n - binomial(floor((1/2)+sqrt(2*(1+n))),2);
-
Mathematica
m[n_]:= Floor[(-1 + Sqrt[8n - 7])/2] b[n_]:= n - m[n] (m[n] + 1)/2 Table[m[n], {n, 1, 105}] (* A003056 *) Table[b[n], {n, 1, 105}] (* A002260 *) Table[b[n] - 1, {n, 1, 120}] (* A002262 *) (* Clark Kimberling, Jun 14 2011 *) Flatten[Table[k, {n, 0, 14}, {k, 0, n}]] (* Alonso del Arte, Sep 21 2011 *) Flatten[Table[Range[0,n], {n,0,15}]] (* Harvey P. Dale, Jan 31 2015 *)
-
PARI
a(n)=n-binomial(round(sqrt(2+2*n)),2)
-
PARI
t1(n)=n-binomial(floor(1/2+sqrt(2+2*n)),2) /* A002262, this sequence */
-
PARI
t2(n)=binomial(floor(3/2+sqrt(2+2*n)),2)-(n+1) /* A025581, cf. comment by Somos for reading arrays by antidiagonals */
-
PARI
concat(vector(15,n,vector(n,i,i-1))) \\ M. F. Hasler, Sep 21 2011
-
PARI
apply( {A002262(n)=n-binomial(sqrtint(8*n+8)\/2,2)}, [0..99]) \\ M. F. Hasler, Oct 20 2022
-
Python
for i in range(16): for j in range(i): print(j, end=", ") # Mohammad Saleh Dinparvar, May 13 2020
-
Python
from math import comb, isqrt def a(n): return n - comb((1+isqrt(8+8*n))//2, 2) print([a(n) for n in range(105)]) # Michael S. Branicky, May 07 2023
Formula
a(n) = A002260(n) - 1.
a(n) = n - (trinv(n)*(trinv(n)-1))/2; trinv := n -> floor((1+sqrt(1+8*n))/2) (cf. A002024); # gives integral inverses of triangular numbers
a(n) = f(n,1) with f(n,m) = if nReinhard Zumkeller, May 20 2009
a(n) = (1/2)*(t - t^2 + 2*n), where t = floor(sqrt(2*n+1) + 1/2) = round(sqrt(2*n+1)). - Ridouane Oudra, Dec 01 2019
a(n) = ceiling((-1 + sqrt(9 + 8*n))/2) * (1 - ((1/2)*ceiling((1 + sqrt(9 + 8*n))/2))) + n. - Ryan Jean, Sep 03 2022
G.f.: x*y/((1 - x)*(1 - x*y)^2). - Stefano Spezia, Feb 21 2024
Extensions
New name from Omar E. Pol, Jul 15 2012
Typo in definition fixed by Reinhard Zumkeller, Aug 05 2015
Comments