A193680 Period 6 sequence 0,1,2,0,2,1.
0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1
Offset: 0
Examples
a(8) = 8(mod 3) = 2 because (-1)^floor(8/3)= +1; 8\3 = 2 is even. a(4) = (3-4)(mod 3) = 2, because (-1)^floor(4/3) is -1; 4\3 = 1 is odd.
Links
- Rémi Guillaume, Formulas for A193680, and some proofs.
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,0,1).
Programs
-
Mathematica
Table[{0, 1, 2, 0, 2, 1}, {15}] // Flatten (* Jean-François Alcover, Jun 21 2013 *) PadRight[{},120,{0,1,2,0,2,1}] (* Harvey P. Dale, Jul 25 2020 *)
-
PARI
a(n)=[0,1,2,0,2,1][n%6+1] \\ Charles R Greathouse IV, Oct 07 2011
Formula
a(n) = n (mod 3) if (-1)^floor(n/3)=+1 else (3 - n)(mod 3), n>=0. (-1)^floor(n/3) is the parity of the quotient floor(n/3), sometimes denoted by n\3.
O.g.f.: x*(1+2*x+2*x^3+x^4)/(1-x^6).
a(n) = 1-((-1)^(n+1)+cos(Pi*n/3)+3*cos(2*Pi*n/3))/3. - R. J. Mathar, Oct 07 2011, corrected by Vaclav Kotesovec, Feb 19 2023
a(n) = floor((71/364)*3^(n+1)) mod 3. - Hieronymus Fischer, Jan 04 2013
a(n) = floor((4007/333333)*10^(n+1)) mod 10. - Hieronymus Fischer, Jan 04 2013
From Amiram Eldar, Jan 01 2023: (Start)
Multiplicative with a(2^e) = 2, a(3^e) = 0, and a(p^e) = 1 for p >= 5.
Dirichlet g.f.: zeta(s)*(1+1/2^s-1/3^s-1/6^s). (End)
Extensions
Keyword:mult added by Andrew Howroyd, Jul 31 2018
Comments