A161989 Numbers having more than 2 or fewer than 2 ones in their binary representation.
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
Keywords
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
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
Comments