login
A209293 as table read layer by layer - layer clockwise, layer counterclockwise and so on.
2

%I #23 Feb 16 2025 08:33:18

%S 1,3,4,2,5,9,14,7,6,10,11,20,23,17,12,8,13,19,26,34,43,30,27,16,15,21,

%T 22,35,38,53,58,48,39,31,24,18,25,33,42,52,63,75,88,69,64,47,44,29,28,

%U 36,37,54,57,76,81,102,109,95,82,70,59,49,40,32,41,51,62

%N A209293 as table read layer by layer - layer clockwise, layer counterclockwise and so on.

%C Permutation of the natural numbers.

%C 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 Layer is 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. Let m be natural number. The order of the list:

%C T(1,1)=1;

%C T(2,1), T(2,2), T(1,2);

%C . . .

%C 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 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 . . .

%C The first row is layer read clockwise, the second row is layer counterclockwise.

%H Boris Putievskiy, <a href="/A214929/b214929.txt">Rows n = 1..140 of triangle, flattened</a>

%H 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 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PairingFunction.html">Pairing functions</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F As table

%F T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.

%F As linear sequence

%F a(n)= (m1+m2-1)*(m1+m2-2)/2+m1, where

%F m1=floor((i+j)/2) + floor(i/2)*(-1)^(2*i+j-1), m2=int((i+j+1)/2)+int(i/2)*(-1)^(2*i+j-2),

%F where 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 The start of the sequence as table:

%e 1....2...5...8..13..18...

%e 3....4...9..12..19..24...

%e 6....7..14..17..26..31...

%e 10..11..20..23..34..39...

%e 15..16..27..30..43..48...

%e 21..22..35..38..53..58...

%e . . .

%e The start of the sequence as triangle array read by rows:

%e 1;

%e 3,4,2;

%e 5,9,14,7,6;

%e 10,11,20,23,17,12,8;

%e 13,19,26,34,43,30,27,16,15;

%e 21,22,35,38,53,58,48,39,31,24,18;

%e . . .

%e Row number r contains 2*r-1 numbers.

%o (Python)

%o t=int((math.sqrt(n-1)))+1

%o i=(t % 2)*min(t,n-(t-1)**2) + ((t+1) % 2)*min(t,t**2-n+1)

%o j=(t % 2)*min(t,t**2-n+1) + ((t+1) % 2)*min(t,n-(t-1)**2)

%o m1=int((i+j)/2)+int(i/2)*(-1)**(2*i+j-1)

%o m2=int((i+j+1)/2)+int(i/2)*(-1)**(2*i+j-2)

%o result=(m1+m2-1)*(m1+m2-2)/2+m1

%Y Cf. A081344, A209293, A209279, A209278, A185180; table T(n,k) contains: in rows A000982, A097063; in columns A000217, A000124, A000096, A152948, A034856, A152950, A055998, A000982, A097063.

%K nonn,changed

%O 1,2

%A _Boris Putievskiy_, Mar 11 2013