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.

A057211 Alternating runs of ones and zeros, where the n-th run has length n.

Original entry on oeis.org

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

Views

Author

Ben Tyner (tyner(AT)phys.ufl.edu), Sep 27 2000

Keywords

Comments

Seen as a triangle read by rows: T(n,k) = n mod 2, 1<=k<=n. - Reinhard Zumkeller, Mar 18 2011
a(A007607(n)) = 0; a(A007606(n)) = 1. - Reinhard Zumkeller, Dec 30 2011
Row sums give A193356. - Omar E. Pol, Mar 05 2014

References

  • K. H. Rosen, Discrete Mathematics and its Applications, 1999, Fourth Edition, page 79, exercise 10 (g).

Crossrefs

Programs

  • Haskell
    a057211 n = a057211_list !! (n-1)
    a057211_list = concat $ zipWith ($) (map replicate [1..]) a059841_list
    -- Reinhard Zumkeller, Mar 18 2011
    
  • Maple
    A002024 := n->round(sqrt(2*n)):A057211 := n->(1-(-1)^A002024(n))/2;
    # alternative Maple program:
    T:= n-> [irem(n, 2)$n][]:
    seq(T(n), n=1..14);  # Alois P. Heinz, Oct 06 2021
  • Mathematica
    Flatten[Table[{PadRight[{},n,1],PadRight[{},n+1,0]},{n,1,21,2}]] (* Harvey P. Dale, Jun 07 2015 *)
  • Python
    from math import isqrt
    def A057211(n): return int(bool(isqrt(n<<3)+1&2)) # Chai Wah Wu, Jun 19 2024

Formula

a(n) = (1-(-1)^A002024(n))/2, where A002024(n)=round(sqrt(2*n)). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 23 2003
Also a(n) = A000035(A002024(n)) = A002024(n) mod 2 = A002024(n)-2*floor(A002024(n)/2). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 23 2003
G.f.: x/(1-x)*sum_{n>=0} (-1)^n*x^(n*(n+1)/2). - Mircea Merca, Mar 05 2014
a(n) = 1 - A057212(n). - Alois P. Heinz, Oct 06 2021

Extensions

Definition amended by Georg Fischer, Oct 06 2021