A221215 T(n,k)= ((n+k)^2-2*(n+k)+4-(n+3*k-2)*(-1)^(n+k))/2; n , k > 0, read by antidiagonals.
1, 6, 5, 2, 3, 4, 15, 14, 13, 12, 7, 8, 9, 10, 11, 28, 27, 26, 25, 24, 23, 16, 17, 18, 19, 20, 21, 22, 45, 44, 43, 42, 41, 40, 39, 38, 29, 30, 31, 32, 33, 34, 35, 36, 37, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 91
Offset: 1
Examples
The start of the sequence as table: 1....6...2..15...7..28..16... 5....3..14...8..27..17..44... 4...13...9..26..18..43..31... 12..10..25..19..42..32..63... 11..24..20..41..33..62..50... 23..21..40..34..61..51..86... 22..39..35..60..52..85..73... . . . The start of the sequence as triangle array read by rows: 1; 6,5; 2,3,4; 15,14,13,12; 7,8,9,10,11; 28,27,26,25,24,23; 16,17,18,19,20,21,22; . . . Row number r contains r consecutive numbers. If r is odd, row is increasing. If r is even, row is decreasing.
Links
- Boris Putievskiy, Rows n = 1..140 of triangle, flattened
- Boris Putievskiy, Transformations [of] Integer Sequences And Pairing Functions arXiv:1212.2732 [math.CO], 2012.
- Eric Weisstein's World of Mathematics, Pairing functions
- Index entries for sequences that are permutations of the natural numbers
Programs
-
Mathematica
T[n_, k_] := ((n+k)^2 - 2(n+k) + 4 - (n+3k-2)(-1)^(n+k))/2; Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Jan 05 2019 *)
-
Python
t=int((math.sqrt(8*n-7) - 1)/ 2) i=n-t*(t+1)/2 j=(t*t+3*t+4)/2-n result=((t+2)**2-2*(t+2)+4-(i+3*j-2)*(-1)**t)/2
Comments