How the conversion works
Repeatedly divide the decimal number by 2 and record the remainder at each step. The binary result is the sequence of remainders read from bottom to top (last remainder first).
For example, decimal 13 divided by 2 gives quotients 6, 3, 1, 0 with remainders 1, 0, 1, 1, producing binary 1101.
Repeat: quotient = n div 2, remainder = n mod 2
Divide by 2 repeatedly, collecting remainders, until the quotient reaches 0.