login
A213196 as table read layer by layer clockwise.
1

%I #14 Nov 29 2023 08:13:55

%S 1,4,5,2,3,7,10,8,6,11,9,17,20,23,14,12,13,16,26,38,43,39,21,24,15,22,

%T 25,30,42,58,63,48,35,31,27,18,19,29,34,57,53,69,76,70,64,49,36,32,28,

%U 37,33,47,52,81,75,95,102,109,88,82,54,59,44,40,41,46,62

%N A213196 as table read layer by layer clockwise.

%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 Call a "layer" a pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1).

%C The order of the list:

%C T(1,1)=1;

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

%C . . .

%C T(1,n), T(2,n), ... T(n-1,n), T(n,n), T(n,n-1), ... T(n,1);

%C . . .

%H Boris Putievskiy, <a href="/A216252/b216252.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="http://mathworld.wolfram.com/PairingFunction.html">MathWorld: Pairing functions</a>

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

%F a(n) = (m1+m2-1)*(m1+m2-2)/2+m1, where m1=(3*i+j-1-(-1)^i+(i+j-2)*(-1)^(i+j))/4, m2=((1+(-1)^i)*((1+(-1)^j)*2*int((j+2)/4)-(-1+(-1)^j)*(2*int((i+4)/4)+2*int(j/2)))-(-1+(-1)^i)*((1+(-1)^j)*(1+2*int(i/4)+2*int(j/2))-(-1+(-1)^j)*(1+2*int(j/4))))/4, i=min(t; n-(t-1)^2), j=min(t; t^2-n+1), t=floor(sqrt(n-1))+1.

%e The start of the sequence as table:

%e 1....4...3..11..13...

%e 2....5...7...9..16...

%e 6....8..10..17..26...

%e 12..14..23..20..38...

%e 15..24..21..39..43...

%e . . .

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

%e 1;

%e 4,5,2;

%e 3,7,10,8,6;

%e 11,9,17,20,23,14,12;

%e 13,16,26,38,43,39,21,24,15;

%e . . .

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

%o (Python)

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

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

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

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

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

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

%Y Cf. A213196, A211377, A214928, A060734, A060736.

%K nonn,tabl

%O 1,2

%A _Boris Putievskiy_, Mar 15 2013