%I #37 Jan 26 2023 19:53:37
%S 0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,
%T 2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,
%U 0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0,3,2,1,0,1,2,3,0
%N Period 8: repeat [0, 1, 2, 3, 0, 3, 2, 1].
%C This sequence can be continued periodically for negative values of n.
%C See a comment on A203571 where a k-family of 2k-periodic sequences P_k has been defined. The present sequence is P_4. - _Wolfdieter Lang_, Feb 02 2012
%H <a href="/index/Rec#order_08">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,0,0,0,1).
%F a(n) = n mod 4 if (-1)^floor(n/4)=+1, otherwise (4-n) mod 4, n >= 0. (-1)^floor(n/4) is the parity of the quotient floor(n/4). This quotient is sometimes denoted by n\4.
%F O.g.f.: x*(1+2*x+3*x^2+3*x^4+2*x^5+x^6)/( (1-x)*(1+x)*(1+x^2)*(1+x^4)).
%F a(n) = floor(410107/33333333*10^(n+1)) mod 10. - _Hieronymus Fischer_, Jan 04 2013
%F a(n) = floor(2323/21845*4^(n+1)) mod 4. - _Hieronymus Fischer_, Jan 04 2013
%e a(10) = 10(mod 4) = 2 because 10\4 = floor(10/4)=2 is even; the parity is +1.
%e a(7) = (4-7)(mod 4) = 1 because 7\4 = floor(7/4)=1 is odd; the parity is -1.
%t PadRight[{}, 120, {0, 1, 2, 3, 0, 3, 2, 1}] (* _Vincenzo Librandi_, Oct 17 2018 *)
%o (PARI) a(n)=[0, 1, 2, 3, 0, 3, 2, 1][n%8+1] \\ _Charles R Greathouse IV_, Oct 16 2015
%o (Magma) &cat [[0, 1, 2, 3, 0, 3, 2, 1]^^15]; // _Vincenzo Librandi_, Oct 17 2018
%o (Python)
%o def A193682(n): return (0,1,2,3,0,3,2,1)[n&7] # _Chai Wah Wu_, Jan 26 2023
%Y Cf. A193680 (mod 3 case).
%Y Cf: A203571.
%K nonn,easy
%O 0,3
%A _Wolfdieter Lang_, Sep 30 2011
|