cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A070402 a(n) = 2^n mod 5.

Original entry on oeis.org

1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1
Offset: 0

Views

Author

N. J. A. Sloane, May 12 2002

Keywords

Comments

Periodic with period 4: [1, 2, 4, 3]. - Washington Bomfim, Nov 23 2010

Crossrefs

Cf. A173635.

Programs

  • GAP
    List([0..83],n->PowerMod(2,n,5)); # Muniru A Asiru, Feb 01 2019
  • Magma
    [Modexp(2, n, 5): n in [0..100]]; // Bruno Berselli, Mar 23 2016
    
  • Maple
    A070402 := proc(n) op((n mod 4)+1,[1,2,4,3]) ; end proc: # R. J. Mathar, Feb 05 2011
  • Mathematica
    PadRight[{}, 100, {1, 2, 4, 3}] (* or *) CoefficientList[Series[(1 + 2 x + 4 x^2 + 3 x^3) / (1 - x^4), {x, 0, 100}], x] (* Vincenzo Librandi, Mar 25 2016 *)
    PowerMod[2,Range[0,120],5] (* Harvey P. Dale, Sep 16 2020 *)
  • PARI
    for(n=0, 80, x=n%4; print1(1 + (15*x^2 -5*x -4*x^3)/6, ", ")) \\ Washington Bomfim, Nov 23 2010
    
  • Sage
    [power_mod(2,n,5) for n in range(0, 105)] # Zerinvary Lajos, Jun 08 2009
    

Formula

From R. J. Mathar, Apr 13 2010: (Start)
a(n) = a(n-1) - a(n-2) + a(n-3).
G.f.: (1 + x + 3*x^2) / ((1-x)*(1+x^2)). (End)
From Washington Bomfim, Nov 23 2010: (Start)
a(n) = 1 + (15*r^2 - 5*r - 4*r^3)/6, where r = n mod 4.
a(n) = A000689(n) - 5*floor(((n-1) mod 4)/2) for n>0. (End)
E.g.f.: (1/2)*(5*exp(x) - 3*cos(x) - sin(x)). - G. C. Greubel, Mar 19 2016