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 A213927 #35 Feb 16 2025 08:33:17 %S A213927 1,2,3,6,5,4,7,8,9,10,11,12,13,14,15,21,20,19,18,17,16,22,23,24,25,26, %T A213927 27,28,29,30,31,32,33,34,35,36,45,44,43,42,41,40,39,38,37,46,47,48,49, %U A213927 50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,78 %N A213927 T(n,k) = (z*(z-1)-(-1+(-1)^(z^2 mod 3))*n+(1+(-1)^(z^2 mod 3))*k)/2, where z=n+k-1; n, k > 0, read by antidiagonals. %C A213927 Self-inverse permutation of the natural numbers. %C A213927 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 A213927 In general, let b(z) be a sequence of integers and denote number of antidiagonal table T(n,k) by z=n+k-1. Natural numbers placed in table T(n,k) by antidiagonals. The order of placement - by antidiagonal downwards, if b(z) is odd; by antidiagonal upwards, if b(z) is even. T(n,k) read by antidiagonals downwards. For A218890 -- the order of placement -- at the beginning m antidiagonals downwards, next m antidiagonals upwards and so on - b(z)=floor((z+m-1)/m). For this sequence b(z)=z^2 mod 3. (This comment should be edited for clarity, _Joerg Arndt_, Dec 11 2014) %H A213927 Boris Putievskiy, <a href="/A213927/b213927.txt">Rows n = 1..140 of triangle, flattened</a> %H A213927 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 A213927 Eric W. Weisstein, <a href="https://mathworld.wolfram.com/PairingFunction.html">MathWorld: Pairing functions</a> %H A213927 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A213927 For the general case. %F A213927 T(n,k) = (z*(z-1)-(-1+(-1)^b(z))*n+(1+(-1)^b(z))*k)/2, where z=n+k-1 (as a table). %F A213927 a(n) = (z*(z-1)-(-1+(-1)^b(z))*i+(1+(-1)^b(z))*j)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2), z=i+j-1 (as a linear sequence). %F A213927 For this sequence b(z)=z^2 mod 3. %F A213927 T(n,k) = (z*(z-1)-(-1+(-1)^(z^2 mod 3))*n+(1+(-1)^(z^2 mod 3))*k)/2, where z=n+k-1 (as a table). %F A213927 a(n) = (z*(z-1)-(-1+(-1)^(z^2 mod 3))*i+(1+(-1)^(z^2 mod 3))*j)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2), z=i+j-1 (as linear sequence). %e A213927 The start of the sequence as table. %e A213927 The direction of the placement denoted by ">" and "v". %e A213927 .v.....v v...v v....v %e A213927 .1.....2...6...7..11...21...22...29...45... %e A213927 .3.....5...8..12..20...23...30...44...47... %e A213927 >4.....9..13..19..24...31...43...48...58... %e A213927 .10...14..18..25..32...42...49...59...75... %e A213927 .15...17..26..33..41...50...60...74...83... %e A213927 >16...27..34..40..51...61...73...84...97... %e A213927 .28...35..39..52..62...72...85...98..114... %e A213927 .36...38..53..63..71...86...99..113..128... %e A213927 >37...54..64..70..87..100..112..129..145... %e A213927 ... %e A213927 The start of the sequence as triangle array read by rows: %e A213927 1; %e A213927 2, 3; %e A213927 6, 5, 4; %e A213927 7, 8, 9, 10; %e A213927 11, 12, 13, 14, 15; %e A213927 21, 20, 19, 18, 17, 16; %e A213927 22, 23, 24, 25, 26, 27, 28; %e A213927 29, 30, 31, 32, 33, 34, 35, 36; %e A213927 45, 44, 43, 42, 41, 40, 39, 38, 37; %e A213927 ... %e A213927 Row r consists of r consecutive numbers from r*r/2-r/2+1 to r*r/2+r. %e A213927 If r is not divisible by 3, rows are increasing. %e A213927 If r is divisible by 3, rows are decreasing. %t A213927 T[n_, k_] := With[{z = n + k - 1}, (z*(z - 1) - (-1 + (-1)^Mod[z^2, 3])*n + (1 + (-1)^Mod[z^2, 3])*k)/2]; %t A213927 Table[T[n - k + 1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Jul 22 2018 *) %o A213927 (Python) %o A213927 t=int((math.sqrt(8*n-7) - 1)/ 2) %o A213927 i=n-t*(t+1)/2 %o A213927 j=(t*t+3*t+4)/2-n %o A213927 z=i+j-1 %o A213927 result=(z*(z-1)-(-1+(-1)**(z**2%3))*i+(1+(-1)**(z**2%3))*j)/2 %Y A213927 Cf. A218890, A056011, A056023, A130196, A011655, A001651, A008585. %K A213927 nonn,tabl,uned %O A213927 1,2 %A A213927 _Boris Putievskiy_, Mar 06 2013