login
A220604
Second inverse function (numbers of columns) for pairing function A081344.
6
1, 1, 2, 2, 3, 3, 3, 2, 1, 1, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
OFFSET
1,3
LINKS
Boris Putievskiy, Transformations Integer Sequences And Pairing Functions, arXiv:1212.2732 [math.CO], 2012.
FORMULA
As a linear array, the sequence is a(n) = mod(t;2)*min{t; t^2 - n + 1} + mod(t + 1; 2)*min{t; n - (t - 1)^2}, where t=floor[sqrt(n-1)]+1.
EXAMPLE
The start of the sequence as triangle array T(n,k) read by rows, row number k contains 2k-1 numbers:
1;
1,2,2;
3,3,3,2,1;
1,2,3,4,4,4,4;
...
If k is even the row is 1,2,...,k,k...k (k times repetition "k" at the end of row).
If k is odd the row is k,k,...k,k-1,k-2,...1 (k times repetition "k" at the start of row).
PROG
(Python)
t=int(math.sqrt(n-1))+1
j=(t % 2)*min(t, t**2-n+1) + ((t+1) % 2)*min(t, n-(t-1)**2)
CROSSREFS
Cf. A081344.
Sequence in context: A283763 A357622 A357621 * A331484 A046918 A238732
KEYWORD
nonn,tabf
AUTHOR
Boris Putievskiy, Dec 17 2012
STATUS
approved