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.

A075897 1 if binary weight of n is 1 or 2, otherwise 0.

Original entry on oeis.org

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

Views

Author

Benoit Cloitre, Mar 29 2003

Keywords

Crossrefs

Programs

  • Mathematica
    Table[If[MemberQ[{1,2},Total[IntegerDigits[n,2]]],1,0],{n,0,120}] (* Harvey P. Dale, Jul 26 2017 *)
  • PARI
    a(n)=(hammingweight(n)+1)\2 == 1 \\ Charles R Greathouse IV, Jan 10 2022
    
  • PARI
    a(n)=(hammingweight(n)) <= 2 && n > 0 \\ David A. Corneth, Jan 11 2022
    
  • Python
    def a(n): return int(bin(n).count('1') in [1, 2])
    print([a(n) for n in range(105)]) # Michael S. Branicky, Jan 11 2022

Formula

a(n) = 1 if n is in A048645, 0 otherwise.
For n>0: a(n) = 0^floor(A000120(n)/3). - Reinhard Zumkeller, Apr 07 2003