This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A220603 #40 Mar 23 2025 23:33:56 %S A220603 1,2,2,1,1,2,3,3,3,4,4,4,4,3,2,1,1,2,3,4,5,5,5,5,5,6,6,6,6,6,6,5,4,3, %T A220603 2,1,1,2,3,4,5,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,7,6,5,4,3,2,1,1,2,3,4, %U A220603 5,6,7,8,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,9,8,7,6,5,4,3,2,1 %N A220603 First inverse function (numbers of rows) for pairing function A081344. %H A220603 Boris Putievskiy, <a href="/A220603/b220603.txt">Rows n = 1..140 of triangle, flattened</a> %H A220603 Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations Integer Sequences And Pairing Functions</a>, arXiv:1212.2732 [math.CO], 2012. %F A220603 As a linear array, the sequence is a(n) = mod(t;2)*min{t; n - (t - 1)^2} + mod(t + 1; 2)*min{t; t^2 - n + 1}, where t=floor[sqrt(n-1)]+1. %e A220603 The start of the sequence as triangle array T(n,k) read by rows, row number k contains 2k-1 numbers: %e A220603 1; %e A220603 2,2,1; %e A220603 1,2,3,3,3; %e A220603 4,4,4,4,3,2,1; %e A220603 ... %e A220603 If k is odd the row is 1,2,...,k,k...k (k times repetition "k" at the end of row). %e A220603 If k is even the row is k,k,...k,k-1,k-2,...1 (k times repetition "k" at the start of row). %t A220603 row[n_] := If[OddQ[n], Range[n-1]~Join~Table[n, {n}], Table[n, {n}]~Join~ Range[n-1, 1, -1]]; %t A220603 row /@ Range[10] // Flatten (* _Jean-François Alcover_, Nov 19 2019 *) %o A220603 (Python) %o A220603 t=int(math.sqrt(n-1))+1 %o A220603 i=(t % 2)*min(t,n-(t-1)**2) + ((t+1) % 2)*min(t,t**2-n+1) %Y A220603 Cf. A081344. %K A220603 nonn,tabf %O A220603 1,2 %A A220603 _Boris Putievskiy_, Dec 16 2012