A203571 Period length 10: [0, 1, 2, 3, 4, 0, 4, 3, 2, 1] repeated.
0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0, 1, 2, 3, 4, 0, 4, 3, 2, 1, 0
Offset: 0
Examples
a(12) = 12 mod 5 = 2 since 12\5 = floor(12/5) = 2 is even; the sign is +1. a(7) = -7 mod 5 = 3 since 7\5 = floor(7/5) = 1 is odd; the sign is -1.
Links
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,0,0,0,0,0,1).
Programs
-
Mathematica
A203571[n_] := {0, 1, 2, 3, 4, 0, 4, 3, 2, 1}[[Mod[n, 10] + 1]]; Table[A203571[n], {n, 0, 59}] (* Jean-François Alcover, Jul 05 2013 *) PadRight[{},120,{0,1,2,3,4,0,4,3,2,1}] (* Harvey P. Dale, May 21 2021 *)
-
PARI
A203571(n)=[0,1,2,3,4,0,4,3,2,1][n%10+1] \\ M. F. Hasler, Jan 13 2013
-
PARI
A203571(n)=151709*5^(n%10+1)\2441406%5 \\ M. F. Hasler, Jan 13 2013
Formula
a(n) = n mod 5 if (-1)^floor(n/5) = +1 else -n mod 5, n >= 0. (-1)^floor(n/5) is the sign corresponding to the parity of the quotient floor(n/5). This quotient is sometimes denoted by n\5.
O.g.f.: x*(1+2*x+3*x^2+4*x^3+4*x^5+3*x^6+2*x^7+x^8)/(1-x^10) = -x*(1 +2*x +3*x^2 +4*x^3 +4*x^5 +3*x^6 +2*x^7 +x^8) / ( (x-1) *(1+x) *(x^4+x^3+x^2+x+1) *(x^4-x^3+x^2-x+1) ).
a(n) = (2/5)*cos(Pi*n) - cos(4*Pi*n/5) - (1/5)*cos(3*Pi*n/5) + (2/5)*5^(1/2)*cos(3*Pi*n/5) - cos(2*Pi*n/5) - (1/5)*cos(Pi*n/5) - (2/5)*5^(1/2)*cos(Pi*n/5) + 2. - Leonid Bedratyuk, May 13 2012
a(n) = floor(123404321/9999999999*10^(n+1)) mod 10. - Hieronymus Fischer, Jan 04 2013
a(n) = floor(151709/2441406*5^(n+1)) mod 5. - Hieronymus Fischer, Jan 04 2013
a(n) = (5-abs(n-(10*ceiling(n/10)-5)))*(ceiling((n+5)/10)-floor((n+5)/10)). - Wesley Ivan Hurt, Mar 26 2014 [corrected by Jason Yuen, Feb 17 2025]
a(n+10) = a(n) for n in Z; a(-n) = a(n) for n in Z. - Rémi Guillaume, Aug 28 2024
Comments