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”).
%I #25 Aug 05 2023 23:27:21
%S 1,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,
%T 3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,0,2,3,
%U 0,2,3,0,2,3,0,2,3,0,2,3,0,2
%N a(n) = a(n-1) + 3 - a(n-1)!.
%C a(0) is taken as 1. The sequence remains essentially the same for a(0)=0,1,2,3.
%C Even though each term is dependent on the previous term, the sequence is repetitive.
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,1).
%F a(n) = a(n-1) + 3 - a(n-1)!.
%F For n > 1, a(n) = (5+4*cos(2*(n+1)*Pi/3) - 2*sqrt(3)*sin(2*(n+1)*Pi/3))/3. - _Wesley Ivan Hurt_, Sep 27 2017
%F a(n) = (floor((4*n - 1)/3) + signum(n - 1)) mod 4. - _Lechoslaw Ratajczak_, Jul 01 2023
%e For n=1, a(1) = a(1-1) + 3 - a(1-1)! = 1 + 3 - 1 = 3.
%e For n=2, a(2) = a(2-1) + 3 - a(2-1)! = 3 + 3 - 6 = 0.
%e For n=3, a(3) = a(3-1) + 3 - a(3-1)! = 0 + 3 - 1 = 2.
%t NestList[#+3-#!&,1,90] (* or *) PadRight[{1},90,{2,3,0}] (* _Harvey P. Dale_, Apr 23 2015 *)
%o (PARI) a(n)=if(n>1, [0, 2, 3][n%3+1], 1) \\ _Charles R Greathouse IV_, Apr 03 2013
%K nonn,easy
%O 1,2
%A _Mihir Mathur_, Apr 03 2013