Search: a209278 -id:a209278
|
|
A209279
|
|
First inverse function (numbers of rows) for pairing function A185180.
|
|
+10
6
|
|
|
1, 1, 2, 2, 1, 3, 2, 3, 1, 4, 3, 2, 4, 1, 5, 3, 4, 2, 5, 1, 6, 4, 3, 5, 2, 6, 1, 7, 4, 5, 3, 6, 2, 7, 1, 8, 5, 4, 6, 3, 7, 2, 8, 1, 9, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1, 11, 6, 7, 5, 8, 4, 9, 3, 10, 2, 11, 1, 12, 7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 1, 13
(list;
table;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
COMMENTS
|
|
|
LINKS
|
|
|
FORMULA
|
a(n) = floor((t+2)/2) + floor(i/2)*(-1)^(i+t+1), where t=floor((-1+sqrt(8*n-7))/2), i=n-t*(t+1)/2.
T(r,2s)=s, T(r,2s-1)= r+s-1.(When read as table T(r,s) by antidiagonals.)
T(n,k) = ceiling((n + (-1)^(n-k)*k)/2) = (n+k)/2 if n-k even, otherwise (n-k+1)/2. - M. F. Hasler, May 30 2020
|
|
EXAMPLE
|
The start of the sequence as table T(r,s) r,s >0 read by antidiagonals:
1...1...2...2...3...3...4...4...
2...1...3...2...4...3...5...4...
3...1...4...2...5...3...6...4...
4...1...5...2...6...3...7...4...
5...1...6...2...7...3...8...4...
6...1...7...2...8...3...9...4...
7...1...8...2...9...3..10...4...
...
The start of the sequence as triangle array read by rows:
1;
1, 2;
2, 1, 3;
2, 3, 1, 4;
3, 2, 4, 1, 5;
3, 4, 2, 5, 1, 6;
4, 3, 5, 2, 6, 1, 7;
4, 5, 3, 6, 2, 7, 1, 8;
...
Row number r contains permutation numbers form 1 to r.
If r is odd (r+1)/2, (r+1)/2-1, (r+1)/2+1,...r-1, 1, r.
If r is even r/2, r/2+1, r/2-1, ... r-1, 1, r.
|
|
MATHEMATICA
|
T[n_, k_] := Abs[(2*k - 1 + (-1)^(n - k)*(2*n + 1))/4];
|
|
PROG
|
(PARI) T(n, k)=abs((2*k-1+(-1)^(n-k)*(2*n+1))/4) \\ Andrew Howroyd, Dec 31 2017
def a(n):
t = int((math.sqrt(8*n-7) - 1)/2);
i = n-t*(t+1)/2;
return int(t/2)+1+int(i/2)*(-1)**(i+t+1)
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|
|
|
|
1, 2, 4, 3, 5, 9, 14, 7, 6, 8, 12, 17, 23, 20, 11, 10, 13, 19, 26, 34, 43, 30, 27, 16, 15, 18, 24, 31, 39, 48, 58, 53, 38, 35, 22, 21, 25, 33, 42, 52, 63, 75, 88, 69, 64, 47, 44, 29, 28, 32, 40, 49, 59, 70, 82, 95, 109, 102, 81, 76, 57, 54, 37, 36, 41, 51, 62
(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.
Layer is pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1). The order of the list:
T(1,1)=1;
T(1,2), T(2,2), T(2,1);
. . .
T(1,n), T(2,n), ... T(n-1,n), T(n,n), T(n,n-1), ... T(n,1);
. . .
|
|
LINKS
|
|
|
FORMULA
|
As table
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n)= (m1+m2-1)*(m1+m2-2)/2+m1, where 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), where i=min(t; n-(t-1)^2), j=min(t; t^2-n+1), t=floor(sqrt(n-1))+1.
|
|
EXAMPLE
|
The start of the sequence as table:
1....2...5...8..13..18...
3....4...9..12..19..24...
6....7..14..17..26..31...
10..11..20..23..34..39...
15..16..27..30..43..48...
21..22..35..38..53..58...
. . .
The start of the sequence as triangle array read by rows:
1;
2,4,3;
5,9,14,7,6;
8,12,17,23,20,11,10;
13,19,26,34,43,30,27,16,15;
18,24,31,39,48,58,53,38,35,22,21;
. . .
Row number r contains 2*r-1 numbers.
|
|
PROG
|
(Python)
t=int((math.sqrt(n-1)))+1
i=min(t, n-(t-1)**2)
j=min(t, t**2-n+1)
m1=int((i+j)/2)+int(i/2)*(-1)**(2*i+j-1)
m2=int((i+j+1)/2)+int(i/2)*(-1)**(2*i+j-2)
result=(m1+m2-1)*(m1+m2-2)/2+m1
|
|
CROSSREFS
|
Cf. A209293, A209279, A209278, A185180, A060734, A060736; table T(n,k) contains: in rows A000982, A097063; in columns A000217, A000124, A000096, A152948, A034856, A152950, A055998, A000982, A097063.
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|
|
A214929
|
|
A209293 as table read layer by layer - layer clockwise, layer counterclockwise and so on.
|
|
+10
2
|
|
|
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, 22, 35, 38, 53, 58, 48, 39, 31, 24, 18, 25, 33, 42, 52, 63, 75, 88, 69, 64, 47, 44, 29, 28, 36, 37, 54, 57, 76, 81, 102, 109, 95, 82, 70, 59, 49, 40, 32, 41, 51, 62
(list;
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.
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:
T(1,1)=1;
T(2,1), T(2,2), T(1,2);
. . .
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);
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);
. . .
The first row is layer read clockwise, the second row is layer counterclockwise.
|
|
LINKS
|
|
|
FORMULA
|
As table
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n)= (m1+m2-1)*(m1+m2-2)/2+m1, where
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),
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.
|
|
EXAMPLE
|
The start of the sequence as table:
1....2...5...8..13..18...
3....4...9..12..19..24...
6....7..14..17..26..31...
10..11..20..23..34..39...
15..16..27..30..43..48...
21..22..35..38..53..58...
. . .
The start of the sequence as triangle array read by rows:
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,22,35,38,53,58,48,39,31,24,18;
. . .
Row number r contains 2*r-1 numbers.
|
|
PROG
|
(Python)
t=int((math.sqrt(n-1)))+1
i=(t % 2)*min(t, n-(t-1)**2) + ((t+1) % 2)*min(t, t**2-n+1)
j=(t % 2)*min(t, t**2-n+1) + ((t+1) % 2)*min(t, n-(t-1)**2)
m1=int((i+j)/2)+int(i/2)*(-1)**(2*i+j-1)
m2=int((i+j+1)/2)+int(i/2)*(-1)**(2*i+j-2)
result=(m1+m2-1)*(m1+m2-2)/2+m1
|
|
CROSSREFS
|
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.
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
Search completed in 0.005 seconds
|