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 A219159 #54 Feb 16 2025 08:33:18 %S A219159 1,4,2,5,3,9,10,6,8,16,25,11,7,15,17,36,24,12,14,18,26,37,35,23,13,19, %T A219159 27,49,50,38,34,22,20,28,48,64,81,51,39,33,21,29,47,63,65,100,80,52, %U A219159 40,32,30,46,62,66,82,101,99,79,53,41,31,45,61,67,83,121 %N A219159 Natural numbers placed in table T(n,k) layer by layer. The order of placement - at the beginning 2 layers counterclockwise, next 2 layers clockwise and so on. T(n,k) read by antidiagonals. %C A219159 Permutation of the natural numbers. %C A219159 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 A219159 In general, let m be natural number. Layer is pair of sides of square table T(n,k) from T(1,n) to T(n,n) and from T(n,n) to T(n,1). Natural numbers placed in the table T(n,k) layer by layer. The order of placement - at the beginning m layers counterclockwise, next m layers clockwise and so on. T(n,k) read by antidiagonals. %C A219159 For m = 1 the result is A081344. This sequence is result for m = 2. %H A219159 Boris Putievskiy, <a href="/A219159/b219159.txt">Rows n = 1..140 of triangle, flattened</a> %H A219159 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 A219159 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PairingFunction.html">Pairing functions</a> %H A219159 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A219159 For general case. %F A219159 As table %F A219159 T(n,k) = ((1 + (-1)^floor((k - 1)/m))*(k^2 - n + 1) - (-1 + (-1)^floor((k - 1)/m))*((k - 1)^2 + n))/2, if k >= n; T(n,k) = ((1 + (-1)^(floor((n - 1)/m) + 1))*(n^2 - k + 1) - (-1 + (-1)^(floor((n - 1)/m) + 1))*((n - 1)^2 +k))/2, if n > k. %F A219159 As linear sequence %F A219159 a(n) = ((1 + (-1)^floor((j - 1)/m))*(j^2 - i + 1) - (-1 + (-1)^floor((j - 1)/m))*((j - 1)^2 + i))/2, if j >= i; a(n) = ((1 + (-1)^(floor((i - 1)/m) + 1))*(i^2 - j + 1) - (-1 + (-1)^(floor((i - 1)/m) + 1))*((i - 1)^2 + j))/2, if i > j; where i = n - t*(t + 1)/2, j = (t*t + 3*t + 4)/2 - n, t = floor((-1 + sqrt(8*n - 7))/2). %F A219159 For this sequence. %F A219159 As table %F A219159 T(n,k) = ((1 + (-1)^floor((k - 1)/2))*(k^2 - n + 1) - (-1 + (-1)^floor((k - 1)/2))*((k - 1)^2 + n))/2, if k >= n; T(n,k) = ((1 + (-1)^(floor((n - 1)/2) + 1))*(n^2 - k + 1) - (-1 + (-1)^(floor((n - 1)/2) + 1))*((n - 1)^2 + k))/2, if n > k. %F A219159 As linear sequence %F A219159 a(n) = ((1 + (-1)^floor((j - 1)/2))*(j^2 - i + 1) - (-1 + (-1)^floor((j - 1)/2))*((j - 1)^2 + i))/2, if j >= i; a(n) = ((1 + (-1)^(floor((i - 1)/2) + 1))*(i^2 - j + 1) - (-1 + (-1)^(floor((i - 1)/2) + 1))*((i - 1)^2 + j))/2, if i > j; where i = n - t*(t + 1)/2, j = (t*t +3*t + 4)/2 - n, t = floor((-1 + sqrt(8*n - 7))/2). %e A219159 The start of the sequence as table. %e A219159 The direction of the placement denotes by ">" and "v". %e A219159 v..v v...v %e A219159 .>1...4...5..10..25..36..37..50... %e A219159 .>2...3...6..11..24..35..38..51... %e A219159 ..9...8...7..12..23..34..39..52... %e A219159 .16..15..14..13..22..33..40..53... %e A219159 >17..18..19..20..21..32..41..54... %e A219159 >26..27..28..29..30..31..42..55... %e A219159 .49..48..47..46..45..44..43..56... %e A219159 .64..63..62..61..60..59..58..57... %e A219159 . . . %e A219159 The start of the sequence as triangle array read by rows: %e A219159 1; %e A219159 4, 2; %e A219159 5, 3, 9; %e A219159 10, 6, 8, 16; %e A219159 25, 11, 7, 15, 17; %e A219159 36, 24, 12, 14, 18, 26; %e A219159 37, 35, 23, 13, 19, 27, 49; %e A219159 50, 38, 34, 22, 20, 28, 48, 64; %e A219159 ... %t A219159 T[n_, k_] := If[k >= n, ((1 + (-1)^Floor[(k-1)/2])(k^2 - n + 1) - (-1 + (-1)^Floor[(k-1)/2])((k-1)^2 + n))/2, ((1 + (-1)^(Floor[(n-1)/2] + 1))(n^2 - k + 1) - (-1 + (-1)^(Floor[(n-1)/2] + 1))((n-1)^2 + k))/2]; %t A219159 Table[T[n-k+1, k], {n, 1, 11}, {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Dec 11 2018 *) %o A219159 (Python) %o A219159 t=int((math.sqrt(8*n-7) - 1)/ 2) %o A219159 i=n-t*(t+1)/2 %o A219159 j=(t*t+3*t+4)/2-n %o A219159 if j >= i: %o A219159 result=((1+(-1)**int((j-1)/2))*(j**2-i+1)-(-1+(-1)**int((j-1)/2))*((j-1)**2 +i))/2 %o A219159 else: %o A219159 result=((1+(-1)**(int((i-1)/2)+1))*(i**2-j+1)-(-1+(-1)**(int((i-1)/2)+1))*((i-1)**2 +j))/2 %o A219159 (Maxima) T(n,k) := if k >= n then ((1 + (-1)^floor((k - 1)/2))*(k^2 - n + 1) - (-1 + (-1)^floor((k - 1)/2))*((k - 1)^2 + n))/2 else ((1 + (-1)^(floor((n - 1)/2) + 1))*(n^2 - k + 1) - (-1 + (-1)^(floor((n - 1)/2) + 1))*((n - 1)^2 +k))/2$ %o A219159 create_list(T(k, n - k), n, 1, 12, k, 1, n - 1); /* _Franck Maminirina Ramaharo_, Dec 11 2018 */ %Y A219159 Cf. A081344, A194280. %K A219159 nonn,tabl %O A219159 1,2 %A A219159 _Boris Putievskiy_, Feb 19 2013