How do you convert different bases? I know how to convert any number into base 10 by using the below method.
Write (6712)base 8 in base 10.
Ans: $6 \times 8^3 + 7 \times 8^2 + 1 \times 8^1 + 2 \times 8^0 = 3530_{10} $
However, I am not sure how to convert a number in base 10 or a different base into a number in a different base (other than 10).
For example, write (101)base 2 in base 8.
Is there a formula to solve such questions? Help would be appreciated.
Thank you.
 A: From base $2$ to base $8$ is pretty easy - simply convert each $3$ digits into a single digit as follows:


*

*$000\rightarrow0$

*$001\rightarrow1$

*$010\rightarrow2$

*$011\rightarrow3$

*$100\rightarrow4$

*$101\rightarrow5$

*$110\rightarrow6$

*$111\rightarrow7$


If the number of digits is not a multiple of $3$, then add $1$ or $2$ leading zeros.
For example: $(011|001|101|001|010)_2=(31512)_8$.

From base $10$ to base $b$, use the following algorithm (shown in an example):
$567382_{10}=?_{8}$


*

*$567382\div8=70922+\frac{\color\red6}{8}$

*$70922\div8=8865+\frac{\color\red2}{8}$

*$8865\div8=1108+\frac{\color\red1}{8}$

*$1108\div8=138+\frac{\color\red4}{8}$

*$138\div8=17+\frac{\color\red2}{8}$

*$17\div8=2+\frac{\color\red1}{8}$

*$2\div8=0+\frac{\color\red2}{8}$


$567382_{10}=2124126_{8}$

If the initial base is not $10$, then you might have a hard time performing the $\div$ operation.
Since you already know how to convert from any base to base $10$, the general method is:


*

*Convert from the source base to base $10$ (as you already know)

*Convert from base $10$ to the target base (as shown in the example above)

