Your objective is to print all unsigned integers less than N, where N is the largest unsigned integer that can be represented by the number of bits specified by the user. The order in which the numbers should appear is decided by the following rules.
- 0 appear first, since its binary representation have zero ones.
- 1,2,4,8,.... appear next in the increasing order. Note that their binary representation have exactly one one.
- 3,5,6,9,.... appear next in the increasing order. Note that their binary representation have exactly two one.
- And so on.
No comments:
Post a Comment