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.

A035214 2 followed by a run of n 1's.

Original entry on oeis.org

2, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    Table[(SquaresR[1, 8*n + 1] + 2)/2, {n, 0, 100}] (* or *) Table[Floor[(3 - Cos[Pi*Sqrt[8*n + 1]])/2], {n,0,100}] (* G. C. Greubel, May 14 2017 *)
  • PARI
    for(n=0,100, print1(floor((3-cos(Pi*sqrt(8*n+1)))/2), ", ")) \\ G. C. Greubel, May 14 2017
    
  • PARI
    a(n) = issquare(n<<3 + 1) + 1; \\ Kevin Ryde, Aug 03 2022
    
  • Python
    from sympy.ntheory.primetest import is_square
    def A035214(n): return int(is_square((n<<3)|1))+1 # Chai Wah Wu, Jun 07 2025

Formula

a(n) = 2 if n is a triangular number, otherwise 1.
Equals A010054(n) + 1.
a(n) = floor((3-cos(Pi*sqrt(8*n+1)))/2). - Carl R. White, Mar 18 2006

Extensions

Typo corrected by Neven Juric, Jan 10 2009