Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
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!)
Search: a036993 -id:a036993
Displaying 1-2 of 2 results found. page 1
     Sort: relevance | references | number | modified | created      Format: long | short | data
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. +10
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.
KEYWORD
nonn,easy,base
AUTHOR
EXTENSIONS
More terms from Erich Friedman
STATUS
approved
A343049 The k-th binary digit of a(n) is the most frequent digit among the first k binary digits of n (in case of a tie, take the k-th binary digit of n). +10
2
0, 1, 2, 7, 0, 5, 6, 31, 0, 9, 10, 31, 8, 29, 30, 127, 0, 1, 2, 23, 0, 21, 22, 127, 0, 25, 26, 127, 24, 125, 126, 511, 0, 1, 2, 39, 0, 37, 38, 127, 0, 41, 42, 127, 40, 125, 126, 511, 0, 33, 34, 119, 32, 117, 118, 511, 32, 121, 122, 511, 120, 509, 510, 2047, 0 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
Leading zeros are taken into account up to the point the number of zeros exceeds the total number of ones.
We scan the binary representation of a number starting from the least significant digit. See A343271 for the other way.
LINKS
FORMULA
a(n) = 0 iff n belongs to A036993.
a(n) = n iff n = 0 or n belongs to A032925.
a(2^k-1) = 2^(2*k-1)-1 for any k > 1.
A070939(a(n)) < 2*A070939(n).
EXAMPLE
The first terms, in decimal and in binary, are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 2 10 10
3 7 11 111
4 0 100 0
5 5 101 101
6 6 110 110
7 31 111 11111
8 0 1000 0
9 9 1001 1001
10 10 1010 1010
11 31 1011 11111
12 8 1100 1000
13 29 1101 11101
14 30 1110 11110
15 127 1111 1111111
PROG
(PARI) a(n, base=2) = { my (d=digits(n, base), t, f=vector(base)); d=concat(vector(#d), d); forstep (k=#d, 1, -1, f[1+d[k]]++; if (vecmax(f)==f[1+d[k]], t=d[k]; ); d[k]=t); fromdigits(d, base) }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 09 2021
STATUS
approved
page 1

Search completed in 0.005 seconds

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 August 6 08:27 EDT 2024. Contains 374960 sequences. (Running on oeis4.)