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”).

Interleave 2*n+1 and 2*n-1.
6

%I #45 Jan 23 2023 16:52:55

%S 1,-1,3,1,5,3,7,5,9,7,11,9,13,11,15,13,17,15,19,17,21,19,23,21,25,23,

%T 27,25,29,27,31,29,33,31,35,33,37,35,39,37,41,39,43,41,45,43,47,45,49,

%U 47,51,49,53,51,55,53,57,55,59,57,61,59,63,61,65,63,67,65,69,67,71,69,73,71,75,73,77,75,79,77,81,79,83,81,85,83,87,85

%N Interleave 2*n+1 and 2*n-1.

%C Partial sums are A097063, whose pairwise sums are A002061.

%C Binomial transform is A097064.

%H Reinhard Zumkeller, <a href="/A097062/b097062.txt">Table of n, a(n) for n = 0..1000</a>

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

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

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

%F a(n) = 2*(n-1) - a(n-1), with a(0)=1. - _Vincenzo Librandi_, Nov 16 2010

%F a(n) = n - 2 + 3*((n-1) mod 2). - _Lechoslaw Ratajczak_, May 21 2021

%F a(n) = a(n-1)+a(n-2)-a(n-3). - _Wesley Ivan Hurt_, May 21 2021

%t LinearRecurrence[{1, 1, -1}, {1, -1, 3}, 100] (* _Amiram Eldar_, May 21 2021 *)

%t With[{nn=91},Riffle[Range[1,nn,2],Range[-1,nn-2,2]]] (* _Harvey P. Dale_, Jan 23 2023 *)

%o (Haskell)

%o import Data.List (transpose)

%o a097062 n = a097062_list !! n

%o a097062_list = concat $ transpose [a005408_list, (-1) : a005408_list]

%o -- _Reinhard Zumkeller_, Apr 16 2015

%o (PARI) a(n)=(2*n-1)/2+3*(-1)^n/2 \\ _Charles R Greathouse IV_, Oct 07 2015

%o (PARI) Vec((1-2*x+3*x^2)/((1-x^2)*(1-x)) + O(x^100)) \\ _Altug Alkan_, Nov 13 2015

%o (Magma) [(2*n-1)/2 + 3*(-1)^n/2 : n in [0..100]]; // _Wesley Ivan Hurt_, May 22 2021

%Y Cf. A005408, A097063, A097064.

%K sign,easy

%O 0,3

%A _Paul Barry_, Jul 22 2004