For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits.
For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$:
- \$ 10110001_{(2)}=177 \$
- \$ 01100011_{(2)}=99 \$
- \$ 11000110_{(2)}=198 \$
- \$ 10001101_{(2)}=141 \$
- \$ 00011011_{(2)}=27 \$
- \$ 00110110_{(2)}=54 \$
- \$ 01101100_{(2)}=108 \$
- \$ 11011000_{(2)}=216 \$
27 is the smallest rotating result. So we output 27 for 177.
Input / Output
You may choose one of the following behaviors:
- Input a positive integer \$n\$. Output its smallest bit rotation as defined above.
- Input a positive integer \$n\$. Output smallest bit rotation for numbers \$1\dots n\$.
- Input nothing, output this infinity sequence.
Due to definition of this sequence. You are not allowed to consider it as 0-indexed, and output smallest bit rotate for \$n-1\$, \$n+1\$ if you choose the first option. However, if you choose the second or the third option, you may optionally include 0 to this sequence, and smallest bit rotation for \$0\$ is defined as \$0\$. In all other cases, handling \$0\$ as an input is not a required behavior.
Test cases
So, here are smallest bit rotate for numbers \$1\dots 100\$:
1 1 3 1 3 3 7 1 3 5
7 3 7 7 15 1 3 5 7 5
11 11 15 3 7 11 15 7 15 15
31 1 3 5 7 9 11 13 15 5
13 21 23 11 27 23 31 3 7 11
15 13 23 27 31 7 15 23 31 15
31 31 63 1 3 5 7 9 11 13
15 9 19 21 23 19 27 29 31 5
13 21 29 21 43 43 47 11 27 43
55 23 55 47 63 3 7 11 15 19