1
Following the algorithm gives the correct result:
1 mod 2 == 1
1 div 2 == 0
This is obvious, but for some reason is less obvious when the "1" is the last step in representing a larger integer.
Represent 49 in base 2:
So the representation in binary is: 110001
.
Can you check that the result is correct?