# Convert from base $10$ to base $5$

I am having a problem converting $727$(base $10$) to base $5$. What is the algorithm to do it?

I am getting the same number when doing so: $7\times 10^2 + 2\times10^1+7\times10^0 = 727$, nothing changes.

Help me figure it out!

You need to count in terms of $5^0, 5^1, 5^2, 5^3$ and $5^4$, not in term of $100 ,10$ and $1$.

Start by the highest power of $5$ smaller than your number, i.e. $5^4=625$ here, and check how much you can multiply it without exceding (this will be a number in $1,2,3,4$).

Take the leftover (base 10, 727-625=102) and repeat until you reach $0$.

You should have \begin{align} 727_{10}&= 625+100+2\\ &= 1\times 5^4+4\times 5^2+2\times 5^0 \\ &= 10402_5. \end{align}

Trick: divide consecutively the quotients by $\;5\;$ and keep aside the residues :

\begin{align*}\frac{727}5=145+\frac25\longrightarrow& \color{red}2\\ \frac{145}5=29\longrightarrow&\color{red}0\\ \frac{29}5=5+\frac45\longrightarrow&\color{red}4\\ \frac55=1\longrightarrow&\color{red}0\\ \frac15=\frac15\longrightarrow&\color{red}1\end{align*}

Now put them in inverse order and voila!

$$727_{10}=10402_5$$

Can you see why it works?

You have to keep dividing by $5$ and write all the remainders.

So

$$727 = 5\cdot 145 + 2$$ $$145 = 5\cdot29 + 0$$ $$29 = 5\cdot5 + 4$$ $$5 = 5\cdot1 + 0$$ $$1 = 5\cdot0 + 1$$

Write all the remainders in reverse: $10402$

The trick is to realize that \begin{align*} 727 &= 625 + 0*125 + 4*25 + 0*5 + 2 \\ &= 5^4 + 0 *5^3 + 4*5^2 + 0*5^1 + 2*5^0. \end{align*} So the answer is $10402$.
\begin{aligned} 727 &= 5 \cdot 145 &+ \color{red}{2}\\ 145 &= 5 \cdot 29 &+ \color{green}{0}\\ 29 &= 5 \cdot 5 &+ \color{blue}{4}\\ 5 &= 5 \cdot 1 &+ \color{magenta}{0}\\ 1 &= 5 \cdot 0 &+ \color{brown}{1} \end{aligned}
Hence the answer is $\color{brown}{1}\color{magenta}{0}\color{blue}{4}\color{green}{0}\color{red}{2}_5 = 1 \cdot 5^4 + 0 \cdot 5^3 + 4 \cdot 5^2 + 0 \cdot 5^1 + 2 \cdot 5^0 = 727$