login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 3
1, 3, 7, 11, 15, 23, 27, 31, 39, 43, 47, 55, 59, 63, 79, 87, 91, 95, 103, 107, 111, 119, 123, 127, 143, 151, 155, 159, 167, 171, 175, 183, 187, 191, 207, 215, 219, 223, 231, 235, 239, 247, 251, 255, 287, 303, 311, 315, 319, 335, 343, 347, 351, 359, 363, 367 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
Even numbers can't appear in this sequence. - Alonso del Arte, Sep 21 2011
LINKS
MATHEMATICA
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 *)
Select[Range[400], Min[Accumulate[Reverse[IntegerDigits[#, 2]/. (0->-1)]]]> 0&] (* Harvey P. Dale, Apr 23 2016 *)
PROG
(Haskell)
a036994 n = a036994_list !! (n-1)
a036994_list = filter ((p 0) . a030308_row) [1, 3 ..] where
p ones [] = ones > 0
p ones (0:bs) = ones > 1 && p (ones - 1) bs
p ones (1:bs) = p (ones + 1) bs
-- Reinhard Zumkeller, Aug 01 2013
(Python)
from itertools import count, islice
def A036994_gen(startvalue=0): # generator of terms >= startvalue
for n in count(max(startvalue, 0)):
s = bin(n)[2:]
c, l = 0, len(s)
for i in range(l):
c += int(s[l-i-1])
if 2*c <= i + 1:
break
else:
yield n
A036994_list = list(islice(A036994_gen(), 20)) # Chai Wah Wu, Dec 31 2021
(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
CROSSREFS
Cf. A030308.
Sequence in context: A246521 A160785 A095100 * A243115 A279106 A172306
KEYWORD
nonn,easy,base
AUTHOR
EXTENSIONS
More terms from Erich Friedman
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 1 03:27 EDT 2024. Contains 372148 sequences. (Running on oeis4.)