A213928 Natural numbers placed in table T(n,k) layer by layer. The order of placement - at the beginning 2 layers counterclockwise, next 1 layer clockwise and so on. T(n,k) read by antidiagonals.
1, 4, 2, 5, 3, 9, 16, 6, 8, 10, 25, 15, 7, 11, 17, 26, 24, 14, 12, 18, 36, 49, 27, 23, 13, 19, 35, 37, 64, 48, 28, 22, 20, 34, 38, 50, 65, 63, 47, 29, 21, 33, 39, 51, 81, 100, 66, 62, 46, 30, 32, 40, 52, 80, 82, 121, 99, 67, 61, 45, 31, 41, 53, 79, 83, 101
Offset: 1
Examples
The start of the sequence as table. The direction of the placement denotes by ">" and "v". ..........v...........v...........v >1....4...5..16..25..26..49..64..65... >2....3...6..15..24..27..48..63..66... .9....8...7..14..23..28..47..62..67... >10..11..12..13..22..29..46..61..68... >17..18..19..20..21..30..45..60..69... .36..35..34..33..32..31..44..59..70... >37..38..39..40..41..42..43..58..71... >50..51..52..53..54..55..56..57..72... .81..80..79..78..77..76..75..74..73... . . . The start of the sequence as triangle array read by rows: 1; 4,2; 5,3,9; 16,6,8,10; 25,15,7,11,17; 26,24,14,12,18,36; 49,27,23,13,19,35,37; 64,48,28,22,20,34,38,50; 65,63,47,29,21,33,39,51,81; . . .
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
-
Python
t=int((math.sqrt(8*n-7) - 1)/ 2) i=n-t*(t+1)/2 j=(t*t+3*t+4)/2-n if j>=i: result=((1+(-1)**(j**2%3-1))*(j**2-i+1)-(-1+(-1)**(j**2%3-1))*((j-1)**2 +i))/2 else: result=((1+(-1)**(i**2%3))*(i**2-j+1)-(-1+(-1)**(i**2%3))*((i-1)**2 +j))/2
Formula
For general case.
As table
T(n,k) = ((1+(-1)^(b(k)-1))*(k^2-n+1)-(-1+(-1)^(b(k)-1))*((k-1)^2 +n))/2, if k >= n;
T(n,k) = ((1+(-1)^b(n))*(n^2-k+1)-(-1+(-1)^b(n))*((n-1)^2 +k))/2, if n >k.
As linear sequence
a(n) = ((1+(-1)^(b(j)-1))*(j^2-i+1)-(-1+(-1)^(b(j)-1))*((j-1)^2 +i))/2, if j >= i;
a(n) = ((1+(-1)^b(i))*(i^2-j+1)-(-1+(-1)^b(i))*((i-1)^2 +j))/2, if i >j;
where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
For this sequence b(z)=z^2 mod 3.
As table
T(n,k) = ((1+(-1)^(k^2 mod 3-1))*(k^2-n+1)-(-1+(-1)^(k^2 mod 3-1))*((k-1)^2 +n))/2, if k >= n;
T(n,k) = ((1+(-1)^(n^2 mod 3))*(n^2-k+1)-(-1+(-1)^(n^2 mod 3))*((n-1)^2 +k))/2, if n >k.
As linear sequence
a(n) = ((1+(-1)^(j^2 mod 3-1))*(j^2-i+1)-(-1+(-1)^(j^2 mod 3-1))*((j-1)^2 +i))/2, if j >= i;
a(n) = ((1+(-1)^(i^2 mod 3))*(i^2-j+1)-(-1+(-1)^(i^2 mod 3))*((i-1)^2 +j))/2, if i >j;
where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
Comments