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 A216253 #22 Mar 23 2025 23:33:46 %S A216253 1,2,5,4,3,7,10,8,6,12,14,23,20,17,9,11,13,16,26,38,43,39,21,24,15,18, %T A216253 27,31,35,48,63,58,42,30,25,22,19,29,34,57,53,69,76,70,64,49,36,32,28, %U A216253 40,44,59,54,82,88,109,102,95,75,81,52,47,33,37,41,46,62 %N A216253 A213196 as table read layer by layer - layer clockwise, layer counterclockwise and so on. %C A216253 Permutation of the natural numbers. %C A216253 a(n) is a pairing function: a function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} is the set of integer positive numbers. %C A216253 Call a "layer" a pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1). Table read by boustrophedonic ("ox-plowing") method. %C A216253 Let m be natural number. The order of the list: %C A216253 T(1,1)=1; %C A216253 T(2,1), T(2,2), T(1,2); %C A216253 . . . %C A216253 T(1,2*m+1), T(2,2*m+1), ... T(2*m,2*m+1), T(2*m+1,2*m+1), T(2*m+1,2*m), ... T(2*m+1,1); %C A216253 T(2*m,1), T(2*m,2), ... T(2*m,2*m-1), T(2*m,2*m), T(2*m-1,2*m), ... T(1,2*m); %C A216253 . . . %C A216253 The first row is layer read clockwise, the second row is layer counterclockwise. %H A216253 Boris Putievskiy, <a href="/A216253/b216253.txt">Rows n = 1..140 of triangle, flattened</a> %H A216253 Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations [of] Integer Sequences And Pairing Functions</a> arXiv:1212.2732 [math.CO], 2012. %H A216253 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PairingFunction.html">Pairing functions</a> %H A216253 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A216253 a(n) = (m1+m2-1)*(m1+m2-2)/2+m1, where m1=(3*i+j-1-(-1)^i+(i+j-2)*(-1)^(i+j))/4, m2=((1+(-1)^i)*((1+(-1)^j)*2*int((j+2)/4)-(-1+(-1)^j)*(2*int((i+4)/4)+2*int(j/2)))-(-1+(-1)^i)*((1+(-1)^j)*(1+2*int(i/4)+2*int(j/2))-(-1+(-1)^j)*(1+2*int(j/4))))/4, i=(t mod 2)*min(t; n-(t-1)^2) + (t+1 mod 2)*min(t; t^2-n+1), j=(t mod 2)*min(t; t^2-n+1) + (t+1 mod 2)*min(t; n-(t-1)^2), t=floor(sqrt(n-1))+1. %e A216253 The start of the sequence as table: %e A216253 1....4...3..11..13... %e A216253 2....5...7...9..16... %e A216253 6....8..10..17..26... %e A216253 12..14..23..20..38... %e A216253 15..24..21..39..43... %e A216253 . . . %e A216253 The start of the sequence as triangular array read by rows: %e A216253 1; %e A216253 2,5,4; %e A216253 3,7,10,8,6; %e A216253 12,14,23,20,17,9,11; %e A216253 13,16,26,38,43,39,21,24,15; %e A216253 . . . %e A216253 Row number r contains 2*r-1 numbers. %o A216253 (Python) %o A216253 t=int((math.sqrt(n-1)))+1 %o A216253 i=(t % 2)*min(t,n-(t-1)**2) + ((t+1) % 2)*min(t,t**2-n+1) %o A216253 j=(t % 2)*min(t,t**2-n+1) + ((t+1) % 2)*min(t,n-(t-1)**2) %o A216253 m1=(3*i+j-1-(-1)**i+(i+j-2)*(-1)**(i+j))/4 %o A216253 m2=((1+(-1)**i)*((1+(-1)**j)*2*int((j+2)/4)-(-1+(-1)**j)*(2*int((i+4)/4)+2*int(j/2)))-(-1+(-1)**i)*((1+(-1)**j)*(1+2*int(i/4)+2*int(j/2))-(-1+(-1)**j)*(1+2*int(j/4))))/4 %o A216253 m=(m1+m2-1)*(m1+m2-2)/2+m1 %Y A216253 Cf. A213196, A081344, A211377, A214929. %K A216253 nonn,tabl %O A216253 1,2 %A A216253 _Boris Putievskiy_, Mar 15 2013