Re: Find all Decimals where Binary number has N number of 1's



On Jul 1, 3:09 pm, Bacle <ba...@xxxxxxxxx> wrote:
On Wed, 01 Jul 2009 09:20:42 EDT, bradles
<b...@xxxxxxxxxxxxxxxxxxxxx>
wrote:

Does anyone know of a formula or algorithm where I
can find all the decimal numbers that contain N
number of 1's when looking at their binary form.

For example:  Say I want to find all the decimal
numbers, that in binary form have 11 ones in them.
See the example table below where the numbers would
d be 2047, 3071, 3583, etc, etc.

Decimal        -> Binary    -> Number of 1's
2047 ->     11111111111 ->               11
3071 ->     101111111111 ->              11
3583 ->     110111111111 ->              11
3839 ->     111011111111 ->              11
3967 ->     111101111111 ->              11
4031 ->     111110111111 ->              11
4063 ->     111111011111 ->              11
etc
etc
etc

Does anyone know a way of putting this into a
formula or algorithm?

Brad.
Let S be the set of powers of two: S = {1, 2, 4, 8,
16, ... }

How many ways are there to chose a subset of S with
exactly 11
members?

rossum

 Nice. So you get |R|x|R|x....x|R| ( 11 times) =
 |R|. I could only tell they were countably-infinite,
 by just spreading the 1's farther and farther out:

That's |N|x|N|x|N|... 11 times.


  0.11111111  (11 consecutive.)
  0.01111111
  0.00111111.
  ...........

   Still, if you just considered decimal binary strings
  with exactly 11 ones, don't you get an uncountable
  nowhere-dense subset of R?.

No.

You get a countable subset of R.

If you like, you can explicitly enumerate them (there are lots of
traversal orders available).

e.g.
{All arrangements with a total of 0 zeroes}
..11111111111
{Followed by all arrangements with a total of 1 zero}
..011111111111
..101111111111
..110111111111
....
{Followed by all arrangements with a total of 2 zeroes}
..0011111111111
..0101111111111
..0110111111111
....
..1001111111111
..1010111111111
....
{Followed by all arrangements with a total of three zeroes}
....

It is, of course, completely irrelevant to the counting argument
whether we are working to the left of the radix point or to the
right. We end up with a countable number of possibilities either way.

Given any string
  s=0.a_1a_2.... with 11 ones, we can always find one
  string s' that is indefinitely close to s, and
  has more than 11 zeros

What string is infinitely close to 0.11111111111 and still has exactly
11 ones?
For that matter, what string containing exactly 11 ones is irrational?
.



Relevant Pages

  • Re: Find all Decimals where Binary number has N number of 1s
    ... number of 1's when looking at their binary form. ... string in this set is a rational number, so the cardinality cannot be larger than |N| above. ... {All arrangements with a total of 0 zeroes} ... {Followed by all arrangements with a total of 1 zero} ...
    (sci.math)
  • Re: 11-string recuerdos- where on the bell curve?
    ...   Yes, a couple of the ornaments in the first section did not come out ... which there is not room for improvement, slurs included, but I do not ... This is my recording of Recuerdos done on six string several years ... a heavier bass? ...
    (rec.music.classical.guitar)
  • Re: Export multiple versions of a query to separate Excel files
    ... If I try to run the code I can select the folder that I want to create ... Dim qdf As DAO.QueryDef ... Dim strSQL As String, strTemp As String, strMgr As String ...
    (microsoft.public.access.externaldata)
  • Re: Using String for new List name
    ...     for line in infile: ... and aclS represents "access control list String." ... My quest, if you will, is to create a list of syslog entries, each ... Since ACL rules can be written with a range of granularity, ...
    (comp.lang.python)
  • Re: Macro to delete rows until a row contains a certain text strin
    ... Dim rngStartCell As Range ... Dim strToFindStart As String ...     'Test if any rows between first and last identifiers ... starting cell to one row before the row containing "KM In". ...
    (microsoft.public.excel.programming)