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.

A161989 Numbers having more than 2 or fewer than 2 ones in their binary representation.

Original entry on oeis.org

0, 1, 2, 4, 7, 8, 11, 13, 14, 15, 16, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 35, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 67, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 24 2009

Keywords

Comments

A000120(a(n)) <> 2.
Complement of A018900; A151774(a(n)) = 0.

Crossrefs

Programs

  • Mathematica
    Select[Range[0,100],DigitCount[#,2,1]!=2&] (* Harvey P. Dale, Mar 11 2013 *)
  • PARI
    isok(n) = hammingweight(n) != 2; \\ Michel Marcus, Nov 01 2019
    
  • Python
    from itertools import count, islice
    from math import comb
    def A161989(n):
        def f(x):
            s = bin(x)[2:]
            c = n-1+comb((l:=len(s))-1,2)
            try:
                c += l-1-s[1:].index('1')
            except:
                pass
            return c
        m, k = n-1, f(n-1)
        while m != k: m, k = k, f(k)
        return m
    def A161989_gen(): # generator of terms
        return filter(lambda n:n.bit_count()!=2,count(0))
    A161989_list = list(islice(A161989_gen(),50)) # Chai Wah Wu, Oct 30 2024