When I first see this problem, will the value be overflow?
the easiest solution for this problem is just tranfer to binary and reverse
PLEASE USE BIT OPERATION
1101 & 1 => 1 (res<<1+1) 1101 >> 1 => 110
110 & 1 => 0 (res<<1+0) 110 >> 1 => 11
therefore we can know our algorithm is that
res<<1 + n&1 n >> 1