(MAGMAMagma) [ IsOdd(n) select (n+3)/2 else n/2+3 : n in [1..10] ]; // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 2006
(MAGMAMagma) [ IsOdd(n) select (n+3)/2 else n/2+3 : n in [1..10] ]; // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 2006
editing
approved
<a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1, 1, -1).
approved
editing
editing
approved
a(1)=2,a(2)=4. For odd n:a(n)=(a(n-1)+a(n-2))/2; for even n: a(n)=(a(n-1)+a(n-2)+3)/2. [From _Vincenzo Librandi. _, Dec 20 2010]
LinearRecurrence[{1, 1, -1}, {2, 4, 3}, 74] (* Robert G. Wilson v, Apr 19, 2012 *)
(MAGMA) [ IsOdd(n) select (n+3)/2 else n/2+3 : n in [1..10] ]; - from // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 2006
(PARI) { for (n=1, 1000, if (n%2, a=(n + 3)/2, a=(n + 6)/2); write("b060762.txt", n, " ", a); ) } [From _\\ _Harry J. Smith_, Jul 11 2009]
approved
editing
LinearRecurrence[{1, 1, -1}, {2, 4, 3}, 74] (* _Robert G. Wilson v, _, Apr 19, 2012 *)
editing
approved
LinearRecurrence[{1, 1, -1}, {2, 4, 3}, 74] (* Robert G. Wilson v, Apr 19, 2012 *)
proposed
editing
editing
proposed
a(n)=a(n-1)+a(n-2)-a(n-3). G.f.: x*(2+2*x-3*x^2)/((1-x)^2*(1+x)). [Colin Barker, Apr 19 2012]
a[1] = 2; a[2] = 4; a[n_] := a[n] = (a[n - 1] + a[n - 2] + If[ OddQ@ n, 0, 3])/2; Array[a, 74]
nonn,easy
approved
editing