OFFSET
1,2
COMMENTS
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.
FORMULA
EXAMPLE
The start of the sequence as table for general case:
1........m+1..2*m+1..3*m+1..4*m+1..5*m+1..6*m+1 ...
m+1......m+2..2*m+2..3*m+2..4*m+2..5*m+2..6*m+2 ...
2*m+1..2*m+2..2*m+3..3*m+3..4*m+3..5*m+3..6*m+3 ...
3*m+1..3*m+2..3*m+3..3*m+4..4*m+4..5*m+4..6*m+4 ...
4*m+1..4*m+2..4*m+3..4*m+4..4*m+5..5*m+5..6*m+5 ...
5*m+1..5*m+2..5*m+3..5*m+4..5*m+5..5*m+6..6*m+6 ...
6*m+1..6*m+2..6*m+3..6*m+4..6*m+5..6*m+6..6*m+7 ...
. . .
The start of the sequence as triangle array read by rows for general case:
1;
m+1, m+1;
2*m+1, m+2, 2*m+1;
3*m+1, 2*m+2, 2*m+2, 3*m+1;
4*m+1, 3*m+2, 2*m+3, 3*m+2, 4*m+1;
5*m+1, 4*m+2, 3*m+3, 2*m+4, 3*m+3, 4*m+2; 5*m+1;
6*m+1, 5*m+2, 4*m+3, 3*m+4, 2*m+5, 3*m+4, 4*m+3; 5*m+2, 6*m+1;
. . .
Row number r contains r numbers: r*m+1, (r-1)*m+2, ... (r-1)*m+2, r*m+1.
PROG
(Python)
t=int((math.sqrt(8*n-7)-1)/2)
result=4*(t+1)+3*max(t*(t+1)/2-n, n-(t*t+3*t+4)/2)
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Boris Putievskiy, Jan 15 2013
STATUS
approved