A256008 Self-inverse permutation of positive integers: 4k+1 is swapped with 4k+3, and 4k+2 with 4k+4.
3, 4, 1, 2, 7, 8, 5, 6, 11, 12, 9, 10, 15, 16, 13, 14, 19, 20, 17, 18, 23, 24, 21, 22, 27, 28, 25, 26, 31, 32, 29, 30, 35, 36, 33, 34, 39, 40, 37, 38, 43, 44, 41, 42, 47, 48, 45, 46, 51, 52, 49, 50, 55, 56, 53, 54, 59, 60, 57, 58, 63, 64, 61, 62, 67, 68, 65, 66, 71, 72, 69, 70, 75, 76, 73, 74, 79
Offset: 1
Links
- Ivan Neretin, Table of n, a(n) for n = 1..10000
- F. Michel Dekking, Jeffrey Shallit, and N. J. A. Sloane, Queens in exile: non-attacking queens on infinite chess boards, Electronic J. Combin., 27:1 (2020), #P1.52.
- Index entries for sequences that are permutations of the natural numbers
- Index entries for linear recurrences with constant coefficients, signature (2,-2,2,-1).
Programs
-
Magma
[n-2*(-1)^((2*n+1-(-1)^n) div 4): n in [1..100]]; // Wesley Ivan Hurt, Oct 13 2015
-
Magma
I:=[3,4,1,2]; [n le 4 select I[n] else 2*Self(n-1)-2*Self(n-2)+2*Self(n-3)-Self(n-4): n in [1..80]]; // Vincenzo Librandi, Oct 14 2015
-
Magma
/* By definition: */ &cat[[4*k+3,4*k+4,4*k+1,4*k+2]: k in [0..20]]; // Bruno Berselli, Oct 19 2015
-
Maple
A256008:=n->n-2*(-1)^((2*n+1-(-1)^n)/4): seq(A256008(n), n=1..100); # Wesley Ivan Hurt, Oct 13 2015
-
Mathematica
Table[BitXor[n - 1, 2] + 1, {n, 77}] CoefficientList[Series[(3 - 2*x - x^2 + 2*x^3)/((x - 1)^2*(x^2 + 1)), {x, 0, 100}], x] (* Wesley Ivan Hurt, Oct 13 2015 *) LinearRecurrence[{2, -2, 2, -1}, {3, 4, 1, 2}, 80] (* Vincenzo Librandi, Oct 14 2015 *)
-
PARI
a(n) = bitxor(n-1,2)+1 \\ Charles R Greathouse IV, May 06 2015
-
PARI
Vec(x*(3-2*x-x^2+2*x^3)/((x-1)^2*(x^2+1)) + O(x^100)) \\ Altug Alkan, Oct 13 2015
-
PARI
a(n) = (-1+I)*((-I)^n+I*I^n)+n \\ Colin Barker, Oct 19 2015
-
Python
def a(n): return ((n-1)^2) + 1 print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Mar 21 2023
Formula
From Wesley Ivan Hurt, Oct 13 2015: (Start)
G.f.: x*(3-2*x-x^2+2*x^3)/((x-1)^2*(x^2+1)).
a(n) = 2*a(n-1)-2*a(n-2)+2*a(n-3)-a(n-4) for n>4.
a(n) = n-2*(-1)^((2*n+1-(-1)^n)/4). (End)
a(n) = (-1+i)*((-i)^n+i*i^n)+n, where i = sqrt(-1). - Colin Barker, Oct 19 2015
a(n) = 1 + A004443(n-1). - Alois P. Heinz, Jan 23 2022
Comments