Task
Find the set of numbers such that the binary representation contains two or more runs of 1
separated by at least one 0
.
For example, the for the numbers that are 4 bits long:
0 0000 (no ones)
1 0001 (only one run)
2 0010 (only one run)
3 0011 (only one run)
4 0100 (only one run)
5 0101 Valid
6 0110 (only one run)
7 0111 (only one run)
8 1000 (only one run)
9 1001 Valid
10 1010 Valid
11 1011 Valid
12 1100 (only one run)
13 1101 Valid
14 1110 (only one run)
15 1111 (only one run)
Input
An integer provided to the application via some input in the range 3 .. 32
. This represents the maximum number of bits to count up to.
The input of n
indicates that the numbers 0 .. 2n-1
need to be examined.
Output
A delimited (your choice) list of all numbers meeting the criteria. The numbers are to be presented in numeric order. An extra trailing delimiter is acceptable. Data structure enclosures (e.g. []
and similar) are also acceptable.
Example
Input: 3
Output: 5
Input: 4
Output: 5, 9, 10, 11, 13
Input: 5
Output: 5, 9, 10, 11, 13, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 29
This is code-golf - the answer with the least amount of bytes wins.
\n
delimiting and putting a\n
on the last line, then,
delimited with a,
trailing should be acceptable too. Updated. \$\endgroup\$[1, 2, 3]
? \$\endgroup\$