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.
%I A036994 #34 Sep 16 2022 08:55:36 %S A036994 1,3,7,11,15,23,27,31,39,43,47,55,59,63,79,87,91,95,103,107,111,119, %T A036994 123,127,143,151,155,159,167,171,175,183,187,191,207,215,219,223,231, %U A036994 235,239,247,251,255,287,303,311,315,319,335,343,347,351,359,363,367 %N A036994 Numbers k with the property that reading from right to left in the binary expansion of k, the number of 1's always stays ahead of the number of 0's. %C A036994 Even numbers can't appear in this sequence. - _Alonso del Arte_, Sep 21 2011 %H A036994 Reinhard Zumkeller, <a href="/A036994/b036994.txt">Table of n, a(n) for n = 1..10000</a> %H A036994 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a> %t A036994 aheadOnesRLQ[n_Integer] := Module[{digits, len, flag = True, iter = 1, ones = 0, zeros = 0}, digits = Reverse[IntegerDigits[n, 2]]; len = Length[digits]; While[flag && iter < len, If[digits[[iter]] == 1, ones++, zeros++]; flag = ones > zeros; iter++]; flag]; Select[Range[1, 201, 2], aheadOnesRLQ] (* _Alonso del Arte_, Sep 21 2011 *) %t A036994 Select[Range[400],Min[Accumulate[Reverse[IntegerDigits[#,2]/. (0->-1)]]]> 0&] (* _Harvey P. Dale_, Apr 23 2016 *) %o A036994 (Haskell) %o A036994 a036994 n = a036994_list !! (n-1) %o A036994 a036994_list = filter ((p 0) . a030308_row) [1, 3 ..] where %o A036994 p ones [] = ones > 0 %o A036994 p ones (0:bs) = ones > 1 && p (ones - 1) bs %o A036994 p ones (1:bs) = p (ones + 1) bs %o A036994 -- _Reinhard Zumkeller_, Aug 01 2013 %o A036994 (Python) %o A036994 from itertools import count, islice %o A036994 def A036994_gen(startvalue=0): # generator of terms >= startvalue %o A036994 for n in count(max(startvalue,0)): %o A036994 s = bin(n)[2:] %o A036994 c, l = 0, len(s) %o A036994 for i in range(l): %o A036994 c += int(s[l-i-1]) %o A036994 if 2*c <= i + 1: %o A036994 break %o A036994 else: %o A036994 yield n %o A036994 A036994_list = list(islice(A036994_gen(),20)) # _Chai Wah Wu_, Dec 31 2021 %o A036994 (PARI) ok(x)={if(x<1,return(0));my(c=logint(x,2),c0=0,c1=0);for(i=0,c,if(bittest(x,i),c1++,c0++);if(c1<=c0,return(0)));1} \\ for(n=1,367,if(ok(n),print1(n,", "))) - _Ruud H.G. van Tol_, Sep 14 2022 %Y A036994 Cf. A036990, A036991, A036992, A036993. %Y A036994 Cf. A030308. %K A036994 nonn,easy,base %O A036994 1,2 %A A036994 _N. J. A. Sloane_ %E A036994 More terms from _Erich Friedman_