login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = n + {1,2,0,1} according as n == {0,1,2,3} mod 4.
12

%I #44 Dec 22 2024 20:16:29

%S 1,3,2,4,5,7,6,8,9,11,10,12,13,15,14,16,17,19,18,20,21,23,22,24,25,27,

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

%U 51,50,52,53,55,54,56,57,59,58,60,61,63,62,64,65,67,66,68

%N a(n) = n + {1,2,0,1} according as n == {0,1,2,3} mod 4.

%C In each group of four consecutive numbers, swap 2nd and 3rd terms. - _Zak Seidov_, Mar 31 2006

%C First differences of A089781. - _Reinhard Zumkeller_, Aug 15 2015

%C From _Guenther Schrack_, May 31 2017: (Start)

%C Permutation of the positive integers partitioned into quadruples [4k+1,4k+3,4k+2,4k+4].

%C Partial sums: A116996. (End)

%H Vincenzo Librandi, <a href="/A116966/b116966.txt">Table of n, a(n) for n = 0..1000</a>

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

%F a(n) = n+1+(i^(n(n-1))-(-1)^n)/2, where i=sqrt(-1). - _Bruno Berselli_, Nov 25 2012

%F G.f.: (2*x^3-x^2+2*x+1) / ((x-1)^2*(x+1)*(x^2+1)). - _Colin Barker_, Apr 30 2013

%F a(n) = A140081(n+2) + n. - _Reinhard Zumkeller_, Aug 15 2015

%F From _Guenther Schrack_, May 31 2017: (Start)

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

%F a(n) = a(n-4) + 4, n > 3.

%F a(n) = a(n-1) + a(n-4) - a(n-5), n > 4. (End)

%F Sum_{n>=0} (-1)^n/a(n) = Pi/4 + log(2)/2. - _Amiram Eldar_, Jan 31 2023

%p f:=proc(i) if i mod 4 = 0 then i+1 elif i mod 4 = 1 then i+2 elif i mod 4 = 2 then i else i+1; fi; end;

%t b := {1, 2, 0, 1}; a[n_] := n + b[[1 + Mod[n, 4]]]; Table[a[n], {n, 0, 60}] (* _Stefan Steinerberger_, Mar 31 2006 *)

%t CoefficientList[Series[(2 x^3 - x^2 + 2 x + 1) / ((x - 1)^2 (x + 1) (x^2 + 1)), {x, 0, 40}], x] (* _Vincenzo Librandi_, Jun 19 2013 *)

%o (Maxima) makelist(n+1+(%i^(n*(n-1))-(-1)^n)/2, n, 0, 70); /* _Bruno Berselli_, Nov 25 2012 */

%o (Magma) /* By definition: */ [ n + [1,2,0,1][1+(n mod 4)]: n in [0..70] ]; // _Bruno Berselli_, Nov 25 2012

%o (PARI) Vec((2*x^3-x^2+2*x+1) / ((x-1)^2*(x+1)*(x^2+1)) + O(x^66) ) \\ _Joerg Arndt_, Apr 30 2013

%o (Haskell)

%o a116966 n = a116966_list !! n

%o a116966_list = zipWith (+) [0..] $ drop 2 a140081_list

%o -- _Reinhard Zumkeller_, Aug 15 2015

%Y Cf. A115391, A116996.

%Y Cf. A140081, A089781.

%K nonn,easy,changed

%O 0,2

%A _N. J. A. Sloane_, Mar 31 2006