A214929 A209293 as table read layer by layer - layer clockwise, layer counterclockwise and so on.
1, 3, 4, 2, 5, 9, 14, 7, 6, 10, 11, 20, 23, 17, 12, 8, 13, 19, 26, 34, 43, 30, 27, 16, 15, 21, 22, 35, 38, 53, 58, 48, 39, 31, 24, 18, 25, 33, 42, 52, 63, 75, 88, 69, 64, 47, 44, 29, 28, 36, 37, 54, 57, 76, 81, 102, 109, 95, 82, 70, 59, 49, 40, 32, 41, 51, 62
Offset: 1
Keywords
Examples
The start of the sequence as table: 1....2...5...8..13..18... 3....4...9..12..19..24... 6....7..14..17..26..31... 10..11..20..23..34..39... 15..16..27..30..43..48... 21..22..35..38..53..58... . . . The start of the sequence as triangle array read by rows: 1; 3,4,2; 5,9,14,7,6; 10,11,20,23,17,12,8; 13,19,26,34,43,30,27,16,15; 21,22,35,38,53,58,48,39,31,24,18; . . . Row number r contains 2*r-1 numbers.
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
Crossrefs
Programs
-
Python
t=int((math.sqrt(n-1)))+1 i=(t % 2)*min(t,n-(t-1)**2) + ((t+1) % 2)*min(t,t**2-n+1) j=(t % 2)*min(t,t**2-n+1) + ((t+1) % 2)*min(t,n-(t-1)**2) m1=int((i+j)/2)+int(i/2)*(-1)**(2*i+j-1) m2=int((i+j+1)/2)+int(i/2)*(-1)**(2*i+j-2) result=(m1+m2-1)*(m1+m2-2)/2+m1
Formula
As table
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n)= (m1+m2-1)*(m1+m2-2)/2+m1, where
m1=floor((i+j)/2) + floor(i/2)*(-1)^(2*i+j-1), m2=int((i+j+1)/2)+int(i/2)*(-1)^(2*i+j-2),
where i=(t mod 2)*min(t; n-(t-1)^2) + (t+1 mod 2)*min(t; t^2-n+1), j=(t mod 2)*min(t; t^2-n+1) + (t+1 mod 2)*min(t; n-(t-1)^2), t=floor(sqrt(n-1))+1.
Comments