%I #13 Jun 13 2015 00:51:06
%S 4,2,4,12,6,12,36,18,36,108,54,108,324,162,324,972,486,972,2916,1458,
%T 2916,8748,4374,8748,26244,13122,26244,78732,39366,78732,236196,
%U 118098,236196,708588,354294,708588,2125764,1062882,2125764,6377292,3188646,6377292,19131876
%N a(1) = 4; a(n) = if n == 2 mod 3 then a(n-1)/2, if n == 0 mod 3 then a(n-1)*2, if n == 1 mod 3 then a(n-1)*3.
%C Given as a puzzle: find the next term after 4, 12, 6, 12, 36, 18, 36! Thanks to Farideh Firoozbakht and Zak Seidov for the solution.
%H <a href="/index/Rec">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,3).
%F a[1] = 4; a[n] = (2 + Mod[n, 3])*8^(-Floor[(1 + Mod[n, 3])/3])*a[n - 1].
%F a(n) = 3^floor((n-1)/3) (4 - 2 floor((n mod 3)/2)). - _Dean Hickerson_, Jul 24, 2003
%F a(n) = 3*a(n-3). G.f.: -2*x*(2*x^2+x+2) / (3*x^3-1). - _Colin Barker_, Jul 31 2013
%p a := proc(n) option remember; if n=1 then 4; elif n mod 3 = 2 then a(n-1)/2 elif n mod 3 = 0 then a(n-1)*2 else a(n-1)*3; fi; end;
%t a[1] = 4; a[n_] := Switch[ Mod[n, 3], 0, 2a[n - 1], 1, 3a[n - 1], 2, a[n - 1]/2]; Table[ a[n], {n, 1, 43}]
%t a[1] = 4; a[n_] := (2 + Mod[n, 3])*8^(-Floor[(1 + Mod[n, 3])/3])*a[n - 1] Do[Print[a[n], {n, 30}]
%K nonn,easy
%O 1,1
%A _N. J. A. Sloane_, Jul 18 2003