Process one bit at a time. Extract the least significant bit from input, append it to the result.
For iterations:
Shift result left by 1 to make room.
Add the last bit of n to result (result |= n & 1).
Shift n right by 1 to move to the next bit.
This effectively reads bits right-to-left and writes them left-to-right.