login
Self-inverse permutation of positive integers: 4k+1 is swapped with 4k+3, and 4k+2 with 4k+4.
6

%I #48 Mar 22 2023 08:15:15

%S 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,

%T 25,26,31,32,29,30,35,36,33,34,39,40,37,38,43,44,41,42,47,48,45,46,51,

%U 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

%N Self-inverse permutation of positive integers: 4k+1 is swapped with 4k+3, and 4k+2 with 4k+4.

%C A lexicographically minimal sequence of distinct positive integers such that a(n)*n + 1 is a square. The same condition without the requirement for a(n) to be distinct would produce A076942.

%H Ivan Neretin, <a href="/A256008/b256008.txt">Table of n, a(n) for n = 1..10000</a>

%H F. Michel Dekking, Jeffrey Shallit, and N. J. A. Sloane, <a href="https://doi.org/10.37236/8905">Queens in exile: non-attacking queens on infinite chess boards</a>, Electronic J. Combin., 27:1 (2020), #P1.52.

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

%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (2,-2,2,-1).

%F From _Wesley Ivan Hurt_, Oct 13 2015: (Start)

%F G.f.: x*(3-2*x-x^2+2*x^3)/((x-1)^2*(x^2+1)).

%F a(n) = 2*a(n-1)-2*a(n-2)+2*a(n-3)-a(n-4) for n>4.

%F a(n) = n-2*(-1)^((2*n+1-(-1)^n)/4). (End)

%F a(n) = (-1+i)*((-i)^n+i*i^n)+n, where i = sqrt(-1). - _Colin Barker_, Oct 19 2015

%F a(n) = 1 + A004443(n-1). - _Alois P. Heinz_, Jan 23 2022

%p A256008:=n->n-2*(-1)^((2*n+1-(-1)^n)/4): seq(A256008(n), n=1..100); # _Wesley Ivan Hurt_, Oct 13 2015

%t Table[BitXor[n - 1, 2] + 1, {n, 77}]

%t 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 *)

%t LinearRecurrence[{2, -2, 2, -1}, {3, 4, 1, 2}, 80] (* _Vincenzo Librandi_, Oct 14 2015 *)

%o (PARI) a(n) = bitxor(n-1,2)+1 \\ _Charles R Greathouse IV_, May 06 2015

%o (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

%o (PARI) a(n) = (-1+I)*((-I)^n+I*I^n)+n \\ _Colin Barker_, Oct 19 2015

%o (Magma) [n-2*(-1)^((2*n+1-(-1)^n) div 4): n in [1..100]]; // _Wesley Ivan Hurt_, Oct 13 2015

%o (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

%o (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

%o (Python)

%o def a(n): return ((n-1)^2) + 1

%o print([a(n) for n in range(1, 81)]) # _Michael S. Branicky_, Mar 21 2023

%Y Cf. A004443, A076942, A269526.

%K nonn,easy

%O 1,1

%A _Ivan Neretin_, May 06 2015