The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 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. 3
 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, 27, 49, 50, 38, 34, 22, 20, 28, 48, 64, 81, 51, 39, 33, 21, 29, 47, 63, 65, 100, 80, 52, 40, 32, 30, 46, 62, 66, 82, 101, 99, 79, 53, 41, 31, 45, 61, 67, 83, 121 (list; table; graph; refs; listen; history; text; internal format)
 OFFSET 1,2 COMMENTS Permutation of the natural numbers. 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. 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. For m = 1 the result is A081344. This sequence is result for m = 2. LINKS Boris Putievskiy, Rows n = 1..140 of triangle, flattened Boris Putievskiy, Transformations [of] Integer Sequences And Pairing Functions arXiv:1212.2732 [math.CO] Eric W. Weisstein, MathWorld: Pairing functions FORMULA For general case. As table 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. As linear sequence 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). For this sequence. As table 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. As linear sequence 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). EXAMPLE The start of the sequence as table.  The direction of the placement denotes by ">" and  "v".           v..v           v...v .>1...4...5..10..25..36..37..50... .>2...3...6..11..24..35..38..51... ..9...8...7..12..23..34..39..52... .16..15..14..13..22..33..40..53... >17..18..19..20..21..32..41..54... >26..27..28..29..30..31..42..55... .49..48..47..46..45..44..43..56... .64..63..62..61..60..59..58..57...   . . . The start of the sequence as triangle array read by rows:    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, 27, 49;   50, 38, 34, 22, 20, 28, 48, 64;    ... MATHEMATICA 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]; Table[T[n-k+1, k], {n, 1, 11}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Dec 11 2018 *) PROG (Python) t=int((math.sqrt(8*n-7) - 1)/ 2) i=n-t*(t+1)/2 j=(t*t+3*t+4)/2-n if j >= i:    result=((1+(-1)**int((j-1)/2))*(j**2-i+1)-(-1+(-1)**int((j-1)/2))*((j-1)**2 +i))/2 else:    result=((1+(-1)**(int((i-1)/2)+1))*(i**2-j+1)-(-1+(-1)**(int((i-1)/2)+1))*((i-1)**2 +j))/2 (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\$ create_list(T(k, n - k), n, 1, 12, k, 1, n - 1); /* Franck Maminirina Ramaharo, Dec 11 2018 */ CROSSREFS Cf. A081344, A194280. Sequence in context: A127914 A218035 A090964 * A213928 A065189 A165275 Adjacent sequences:  A219156 A219157 A219158 * A219160 A219161 A219162 KEYWORD nonn,tabl AUTHOR Boris Putievskiy, Feb 19 2013 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified February 18 15:04 EST 2020. Contains 332019 sequences. (Running on oeis4.)