login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(3n) = 2n, a(3n+1) = 2n+2, a(3n+2) = 2n+1.
1

%I #22 Sep 22 2024 02:02:29

%S 0,2,1,2,4,3,4,6,5,6,8,7,8,10,9,10,12,11,12,14,13,14,16,15,16,18,17,

%T 18,20,19,20,22,21,22,24,23,24,26,25,26,28,27,28,30,29,30,32,31,32,34,

%U 33,34,36,35,36,38,37,38,40,39,40,42,41,42,44,43,44,46,45,46,48,47,48,50

%N a(3n) = 2n, a(3n+1) = 2n+2, a(3n+2) = 2n+1.

%H Vincenzo Librandi, <a href="/A131380/b131380.txt">Table of n, a(n) for n = 0..2000</a>

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

%F G.f.: x*(2-x+x^2)/((x-1)^2*(1+x+x^2)); a(n) = a(n-1)+a(n-3)-a(n-4); a(n) = (-n mod 3) + 2*floor(n/3) = A080425(n) + 2*A002264(n). - _Wesley Ivan Hurt_, Aug 20 2014

%F E.g.f.: ((2*z+1)/3)*exp(z)+((5/9)*sqrt(3)*sin(sqrt(3)*z/2)-(1/3)*cos(sqrt(3)*z/2))*exp(-z/2). - _Robert Israel_, Aug 21 2014

%F a(n) = (6*n+3-6*cos(2*(n+4)*Pi/3)-4*sqrt(3)*sin(2*(n+4)*Pi/3))/9. - _Wesley Ivan Hurt_, Sep 26 2017

%p A131380:=n->(-n mod 3) + 2*floor(n/3): seq(A131380(n), n=0..100); # _Wesley Ivan Hurt_, Aug 20 2014

%t Table[Mod[-n, 3] + 2 Floor[n/3], {n, 0, 100}] (* _Wesley Ivan Hurt_, Aug 20 2014 *)

%t CoefficientList[Series[x*(2 - x + x^2)/((x - 1)^2 (1 + x + x^2)), {x, 0, 100}], x] (* _Wesley Ivan Hurt_, Aug 20 2014 *)

%t LinearRecurrence[{1, 0, 1, -1}, {0, 2, 1, 2}, 200] (* _Vincenzo Librandi_, Sep 27 2017 *)

%o (Magma) [(-n mod 3) + 2*Floor(n/3) : n in [0..100]]; // _Wesley Ivan Hurt_, Aug 20 2014

%o (Magma) I:=[0,2,1,2]; [n le 4 select I[n] else Self(n-1)+Self(n-3)-Self(n-4): n in [1..100]]; // _Vincenzo Librandi_, Sep 27 2017

%Y Cf. A002264, A080425.

%K nonn,easy

%O 0,2

%A _Paul Curtz_, Oct 01 2007