Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A213194
First inverse function (numbers of rows) for pairing function A211377.
1
1, 1, 1, 2, 2, 3, 1, 1, 2, 2, 3, 3, 4, 4, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10
OFFSET
1,4
FORMULA
a(n) = (3*A002600(n)+A004736(n)-1-(-1)^A002260(n)+A003056(n)*(-1)^A003057(n))/4;
a(n) = (3*i+j-1-(-1)^i+(i+j-2)*(-1)*t)/4, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
EXAMPLE
The start of the sequence as triangle array read by rows:
1;
1,1;
2,2,3;
1,1,2,2;
3,3,4,4,5;
1,1,2,2,3,3;
4,4,5,5,6,6,7;
1,1,2,2,3,3,4,4;
5,5,6,6,7,7,8,8,9;
1,1,2,2,3,3,4,4,5,5;
. . .
The start of the sequence as array read by rows, the length of row r is 4*r-3.
First 2*r-2 numbers are from the row number 2*r-2 of above triangle array.
Last 2*r-1 numbers are from the row number 2*r-1 of above triangle array.
1;
1,1,2,2,3;
1,1,2,2,3,3,4,4,5;
1,1,2,2,3,3,4,4,5,5,6,6,7;
1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9;
. . .
Row r contains numbers 1,2,3,...2*r-2 repeated twice, row ends 2*r-1.
PROG
(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=(3*i+j-1-(-1)**i+(i+j-2)*(-1)**(i+j))/4
CROSSREFS
KEYWORD
nonn
AUTHOR
Boris Putievskiy, Mar 01 2013
STATUS
approved