A209301 Table T(n,k) n, k > 0, T(n,k)=n-k+1, if n>=k, T(n,k)=k-n+2, if n < k. Table read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1).
1, 3, 1, 2, 4, 3, 1, 2, 3, 5, 4, 3, 1, 2, 3, 4, 6, 5, 4, 3, 1, 2, 3, 4, 5, 7, 6, 5, 4, 3, 1, 2, 3, 4, 5, 6, 8, 7, 6, 5, 4, 3, 1, 2, 3, 4, 5, 6, 7, 9, 8, 7, 6, 5, 4, 3, 1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 9, 8, 7
Offset: 1
Examples
The start of the sequence as table for the general case: 1, m, m+1, m+2, m+3, m+4, m+5, ... 2, 1, m, m+1, m+2, m+3, m+4, ... 3, 2, 1, m, m+1, m+2, m+3, ... 4, 3, 2, 1, m, m+1, m+2, ... 5, 4, 3, 2, 1, m, m+1, ... 6, 5, 4, 3, 2, 1, m, ... 7, 6, 5, 4, 3, 2, 1, ... ... The start of the sequence as triangle array read by rows for the general case: 1; m,1,2; m+1,m,1,2,3; m+2,m+1,m,1,2,3,4; m+3,m+2,m+1,m,1,2,3,4,5; m+4, m+3,m+2,m+1,m,1,2,3,4,5,6; m+5, m+4, m+3,m+2,m+1,m,1,2,3,4,5,6,7; ... Row number r contains 2*r -1 numbers: m+r-2, m+r-1,...m,1,2,...r. The start of the sequence as triangle array read by rows for m=3: 1; 3,1,2; 4,3,1,2,3; 5,4,3,1,2,3,4; 6,5,4,3,1,2,3,4,5; 7,6,5,4,3,1,2,3,4,5,6; 8,7,6,5,4,3,1,2,3,4,5,6,7; ...
Links
- Boris Putievskiy, Rows n = 1..140 of triangle, flattened
- Boris Putievskiy, Transformations Integer Sequences And Pairing Functions, arXiv:1212.2732 [math.CO], 2012.
Programs
-
Python
t=int((math.sqrt(n))-0.5)+1 v=int((n-1)/t)-t+1 result=k*v+(2*v-1)*(t**2-n)+t
Formula
For the general case
a(n) = m*v+(2*v-1)*(t*t-n)+t,
where
t = floor(sqrt(n)-1/2)+1,
v = floor((n-1)/t)-t+1.
For m=3
a(n) = 3*v+(2*v-1)*(t*t-n)+t,
where
t = floor(sqrt(n)-1/2)+1,
v = floor((n-1)/t)-t+1.
Comments