3. The next number in the sequence
Given a number n, find the next largest number m such that it contains the same number of 1s in its binary representation.
Sample Input:
10 12 92
Sample Output:
12 17 99
Binary representations of numbers used
| Decimal | Binary |
|---|---|
| 10 | 1010 |
| 12 | 1100 |
| 17 | 10001 |
| 92 | 1011100 |
| 99 | 1100011 |