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 A216249 #28 Feb 16 2025 08:33:18 %S A216249 1,3,2,4,5,6,8,7,12,11,9,10,13,14,15,17,16,21,20,25,24,18,19,22,23,26, %T A216249 27,28,30,29,34,33,38,37,42,41,31,32,35,36,39,40,43,44,45,47,46,51,50, %U A216249 55,54,59,58,63,62,48,49,52,53,56,57,60,61,64,65,66,68,67,72,71,76,75,80,79,84,83,88,87 %N A216249 T(n,k) = ((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2-2, if k=1 and (n mod 2)=1; T(n,k)=((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2, else. Table T(n,k) read by antidiagonals; n , k > 0. %C A216249 Permutation of the natural numbers. %C A216249 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 A216249 Enumeration table T(n,k). Let m be natural number. The order of the list: %C A216249 T(1,1)=1; %C A216249 T(2,1), T(1,2), T(1,3), T(2,2), T(3,1); %C A216249 . . . %C A216249 T(2,2*m-1), T(1,2*m), T(1,2*m+1), T(2,2*m), T(2*m-3,4), ... T(2*m,1), T(2*m-1,2), T(2*m-1,3), T(2*m,2), T(2*m+1,1); %C A216249 . . . %C A216249 Movement along two adjacent antidiagonals - step to the northeast, step to the east, step to the southwest, 3 steps to the west, 2 steps to the south and so on. %C A216249 The length of each step is 1. %H A216249 Boris Putievskiy, <a href="/A216249/b216249.txt">Rows n = 1..140 of triangle, flattened</a> %H A216249 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 A216249 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PairingFunction.html">Pairing functions</a> %H A216249 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A216249 As a table: %F A216249 T(n,k) = ((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2-2, if k=1 and (n mod 2)=1; %F A216249 T(n,k) = ((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2, else. %F A216249 As a linear sequence: %F A216249 a(n) = ((t+2)^2-4*j+3-2*(-1)^i+(-1)^j-(t-2)*(-1)^t)/2-2, if j=1 and (i mod 2)=1; %F A216249 a(n) = ((t+2)^2-4*j+3-2*(-1)^i+(-1)^j-(t-2)*(-1)^t)/2, else; where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2). %e A216249 The start of the sequence as table: %e A216249 1 3 4 8 9 17 18... %e A216249 2 5 7 10 16 19 29... %e A216249 6 12 13 21 22 34 35... %e A216249 11 14 20 23 33 36 50... %e A216249 15 25 26 38 39 55 56... %e A216249 24 27 37 40 54 57 75... %e A216249 28 42 43 59 60 80 81... %e A216249 ... %e A216249 The start of the sequence as triangular array read by rows: %e A216249 1; %e A216249 3, 2; %e A216249 4, 5, 6; %e A216249 8, 7, 12, 11; %e A216249 9, 10, 13, 14, 15; %e A216249 17, 16, 21, 20, 25, 24; %e A216249 18, 19, 22, 23, 26, 27, 28; %e A216249 ... %e A216249 As an array read by rows, where the length of row number r is 4*r-3: %e A216249 First 2*r-2 numbers are from the row number 2*r-2 of triangle array, located above. %e A216249 Last 2*r-1 numbers are from the row number 2*r-1 of triangle array, located above. %e A216249 1; %e A216249 3, 2, 4, 5, 6; %e A216249 8, 7, 12, 11, 9, 10, 13, 14, 15; %e A216249 17, 16, 21, 20, 25, 24, 18, 19, 22, 23, 26, 27, 28; %e A216249 ... %e A216249 Row number r contains permutation of the 4*r-3 numbers from 2*r*r-5*r+4 to 2*r*r-r: %e A216249 2*r*r-5*r+5, 2*r*r-5*r+4, ...2*r*r-r-1, 2*r*r-r. %t A216249 T[n_, k_] := ((n+k)^2 - 4k + 3 - 2(-1)^n + (-1)^k - (n+k-4)(-1)^(n+k))/2 - 2Boole[k == 1 && OddQ[n]]; %t A216249 Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Nov 20 2019 *) %o A216249 (Python) %o A216249 t=int((math.sqrt(8*n-7) - 1)/ 2) %o A216249 i=n-t*(t+1)/2 %o A216249 j=(t*t+3*t+4)/2-n %o A216249 result=((t+2)**2-4*j+3+(-1)**j-2*(-1)**i-(t-2)*(-1)**t)/2 %o A216249 if j==1 and (i%2)==1: %o A216249 result=result-2 %Y A216249 Cf. A213205, A213171, A213197, A210521; table T(n,k) contains: in rows A100037, A033816, A130883, A100039, A100038; in columns A000384, A071355, A091823, A014106. %K A216249 nonn,tabl %O A216249 1,2 %A A216249 _Boris Putievskiy_, Mar 14 2013