login
A131743
Period 4: repeat [0, 1, 0, 2].
7
0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0
OFFSET
0,4
COMMENTS
Least positive integer k such that n^k == 1 (mod 4), or 0 if GCD(n,4) > 1. - Bruno Berselli, Mar 22 2016
FORMULA
G.f.: x*(1+2*x^2)/ ((1-x)*(x+1)*(x^2+1)). - R. J. Mathar, Nov 15 2007
a(n) = 3/4-1/2*sin(1/2*Pi*n)+3/4*(-1)^(1+n). - R. J. Mathar, Nov 15 2007
a(n) = Fibonacci(2*n) mod 3. - Gary Detlefs Feb 13 2011
a(n) == A006368(n) (mod 3). - Philippe Deléham, Oct 24 2011
a(n) = a(n-4) for n>3. - Wesley Ivan Hurt, Jul 09 2016
MAPLE
seq(op([0, 1, 0, 2]), n=0..50); # Wesley Ivan Hurt, Jul 09 2016
MATHEMATICA
PadRight[{}, 106, {0, 1, 0, 2}] (* Harvey P. Dale, Apr 06 2012 *)
CoefficientList[Series[x (1 + 2 x^2)/((1 - x) (x + 1) (x^2 + 1)), {x, 0, 120}], x] (* Michael De Vlieger, Jul 09 2016 *)
PROG
(Magma) &cat [[0, 1, 0, 2]^^30]; // Bruno Berselli, Mar 22 2016
(PARI) x='x+O('x^200); concat(0, Vec(-x*(1+2*x^2)/((x-1)*(x+1)*(x^2+1)))) \\ Altug Alkan, Mar 22 2016
(PARI) a(n)=n%2*(n%4+1)/2 \\ Charles R Greathouse IV, Mar 22 2016
(Python)
def A131743(n): return (0, 1, 0, 2)[n&3] # Chai Wah Wu, Jul 29 2023
CROSSREFS
Cf. A006368.
Sequence in context: A194591 A070105 A111397 * A357860 A147648 A363879
KEYWORD
nonn,easy
AUTHOR
Paul Curtz, Sep 20 2007
STATUS
approved