A025581 Triangle read by rows: T(n, k) = n-k, for 0 <= k <= n.
0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3
Offset: 0
Examples
The triangle T(n, k) begins (note that one could use l <= k <= n, for any integer l, especially 1): n\k 0 1 2 3 4 5 6 7 8 9 10 ... 0: 0 1: 1 0 2: 2 1 0 3: 3 2 1 0 4: 4 3 2 1 0 5: 5 4 3 2 1 0 6: 6 5 4 3 2 1 0 7: 7 6 5 4 3 2 1 0 8: 8 7 6 5 4 3 2 1 0 9: 9 8 7 6 5 4 3 2 1 0 10: 10 9 8 7 6 5 4 3 2 1 0 ... [formatted by _Wolfdieter Lang_, May 12 2015]
References
- H.-W. Alten et al., 4000 Jahre Algebra, 2. Auflage, Springer, 2014, p. 203.
Links
- Reinhard Zumkeller, Rows n = 0..100 of triangle, flattened
- Ângela Mestre and José Agapito, Square Matrices Generated by Sequences of Riordan Arrays, J. Int. Seq., Vol. 22 (2019), Article 19.8.4.
- Boris Putievskiy, Transformations Integer Sequences And Pairing Functions arXiv:1212.2732 [math.CO], 2012.
- Michael Somos, Sequences used for indexing triangular or square arrays
- Eric Weisstein's World of Mathematics, Pairing Function.
Crossrefs
Programs
-
Haskell
a025581 n k = n - k a025581_row n = [n, n-1 .. 0] a025581_tabl = iterate (\xs@(x:_) -> (x + 1) : xs) [0] -- Reinhard Zumkeller, Aug 04 2014, Jul 22 2012, Mar 07 2011
-
Magma
/* As triangle */ [[(n-k): k in [1..n]]: n in [1.. 15]]; // Vincenzo Librandi, Sep 13 2015
-
Maple
A025581 := n -> binomial(1+floor((1/2)+sqrt(2*(1+n))),2) - (n+1): seq(A025581(n), n=0..100);
-
Mathematica
Flatten[NestList[Prepend[#, #[[1]]+1]&, {0}, 13]] (* Jean-François Alcover, May 17 2011 *) With[{nn=20},Flatten[Table[Join[{0},Reverse[Range[i]]],{i,nn}]]] (* Harvey P. Dale, Dec 31 2014 *) Table[Range[n,0,-1],{n,0,15}]//Flatten (* Harvey P. Dale, Aug 01 2020 *)
-
PARI
a(n)=binomial(1+floor(1/2+sqrt(2+2*n)),2)-(n+1) /* produces a(n) */
-
PARI
t1(n)=binomial(floor(3/2+sqrt(2+2*n)),2)-(n+1) /* A025581 */
-
PARI
t2(n)=n-binomial(floor(1/2+sqrt(2+2*n)),2) /* A002262 */
-
PARI
apply( {A025581(n)=binomial(sqrtint(8*n+1)\/2+1,2)-n-1}, [0..90]) \\ M. F. Hasler, Dec 06 2019
-
Python
from math import isqrt, comb def A025581(n): return comb((m:=isqrt(k:=n+1<<1))+(k>m*(m+1))+1,2)-n-1 # Chai Wah Wu, Nov 08 2024
Formula
T(n, k) = n-k, for 0 <= k <= n.
As a sequence: a(n) = (((trinv(n)-1)*(((1/2)*trinv(n))+1))-n), with trinv(n) = floor((1+sqrt(1+8*n))/2). Cf. A002262.
a(n) = A004736(n+1) - 1.
G.f. for T(n,k): y / ((1-x)^2 * (1-x*y)). - Ralf Stephan, Jan 25 2005
For the cubic equation satisfied by T(n, k) see the comment on a problem by Viète above. - Wolfdieter Lang, May 12 2015
G.f. for a(n): -(1-x)^(-2) + (1-x)^(-1) * Sum_{n>=0} (n+1)*x^(n*(n+1)/2). The sum is related to Jacobi theta functions. - Robert Israel, May 12 2015
T(n, k) = sqrt((4*A105125(n, k) - A051162(n, k)^3)/(3*A051162(n, k))). See a comment above. - Wolfdieter Lang, May 15 2015
a(n) = (1/2)*(t^2 + t - 2*n - 2), where t = floor(sqrt(2*n+1) + 1/2) = round(sqrt(2*n+1)). - Ridouane Oudra, Dec 01 2019
a(n) = ((1/2) * ceiling((-1 + sqrt(9 + 8 * n))/2) * ceiling((1 + sqrt(9 + 8 * n))/2)) - n - 1. - Ryan Jean, Apr 22 2022
Extensions
Typo in definition corrected by Arkadiusz Wesolowski, Nov 24 2011
Edited (part of name moved to first comment; definition of trinv added in formula) by Wolfdieter Lang, May 12 2015
Comments