result
to 0.n
using n & 1
.
b. Shift this bit to its reversed position, which is 31 - i
where i
is the current iteration index.
c. Use the OR operation to add the reversed bit to the result
.
d. Shift n
to the right by 1 to process the next bit.result
.