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.

A158581 Numbers having in binary representation at least two ones and two zeros.

This page as a plain text file.
%I A158581 #22 Dec 24 2024 22:12:25
%S A158581 9,10,12,17,18,19,20,21,22,24,25,26,28,33,34,35,36,37,38,39,40,41,42,
%T A158581 43,44,45,46,48,49,50,51,52,53,54,56,57,58,60,65,66,67,68,69,70,71,72,
%U A158581 73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,96,97
%N A158581 Numbers having in binary representation at least two ones and two zeros.
%H A158581 Reinhard Zumkeller, <a href="/A158581/b158581.txt">Table of n, a(n) for n = 1..10000</a>
%F A158581 A023416(a(n)) > 1; A000120(a(n)) > 1.
%t A158581 Select[Range[100],Min[DigitCount[#,2]]>1&] (* _Harvey P. Dale_, Mar 09 2013 *)
%o A158581 (Python)
%o A158581 def ok(n): b = bin(n)[2:]; return b.count('0') >= 2 and b.count('1') >= 2
%o A158581 print(list(filter(ok, range(98)))) # _Michael S. Branicky_, Sep 10 2021
%o A158581 (Python)
%o A158581 def A158581(n):
%o A158581     def f(x):
%o A158581         c = n+((l:=(x+1).bit_length())*(l+1)>>1)-3
%o A158581         m = bin(x+1)[2:].find('0')
%o A158581         c += m if m>-1 else l
%o A158581         return c
%o A158581     m, k = n, f(n)
%o A158581     while m != k: m, k = k, f(k)
%o A158581     return m # _Chai Wah Wu_, Dec 24 2024
%Y A158581 Intersection of A158582 and A057716.
%Y A158581 Cf. A007088, A000120, A023416
%K A158581 nonn,base
%O A158581 1,1
%A A158581 _Reinhard Zumkeller_, Apr 16 2009