How to change from base $n$ to $m$ Does anyone know of an algorithm or formula for converting between and arbitrary base $n$ to another base $m$?
 A: One straightforward way is to write the number in (nested) Horner polynomial form then do the base conversion as an "evaluation" into the target radix, e.g. let's convert $397$ from radix $10$ into radix $\color{#c00}9,\,$ where $\rm\color{#c00}{red}$ numbers are in radix $\color{#c00}9$
$$\begin{align} 397 
\,&=\, (3\cdot 10\, +\, 9)\,10 +7\\
&=\, (\color{#c00}{3\cdot 11+10})10+7,\ \ {\rm by}\ \ 10_{10} = \color{#c00}{11}_9,\ 9_{10} = \color{#c00}{10}_9\\
&=\qquad\quad\ \  \color{#c00}{43\cdot 11}+7\\
&=\qquad\qquad\ \ \ \color{#c00}{473}+7\\
&=\qquad\qquad\ \ \ \color{#c00}{481}\end{align}$$
This yields an obvious recursive algorithm: for a digit list $\rm\, [d_0,d_1,\cdots,d_k]\,$ denoting $\rm\, d_0 + n\,(d_1 + n\,(d_2 + \cdots + d_k))\,$ in radix $\rm\,n,\,$ recursively compute the radix $\rm\,m\,$ representation of the tail $\rm\,[d_1,d_2,\cdots,d_k],\,$ then, employing radix $\rm\,m\,$ operations, multiply it by $\rm\,n\,$ then add $\rm\,d_0,\,$ after converting both to radix $\rm\,m.\,$ Said more succinctly
$$\rm [d_0,d_1,\cdots,d_k]^{(n\ \mapsto\ m)}\ =\,\ d_0^{(n\ \mapsto\ m)}\ +\ n^{(n\ \mapsto\ m)}\ *\ [d_1,d_2,\cdots, d_k]^{(n\ \mapsto\ m)}\qquad$$
Unwinding this recursion, it amounts to applying the conversion operation $\rm\,(\ \ )^{\ (n\ \mapsto\ m)}\,$ to all terms in the fully expanded Horner form given above. Note that this conversion map commutes with $\,\!+\,\!$ and $\,\!*\,\!$ because it is a ring isomorphism from the integers represented in radix $\rm\,n\,$ to the integers represented in radix $\rm\,m.\,$ We are essentially using this isomorphism to transport structure between the rings - here the structure being the polynomial form that is implicit in radix representation.
Various optimizations are possible. For example, for fixed $\rm\,n > m\,$ we can precompute a table mapping the digits in radix $\rm\,n\,$ to their radix $\rm\,m\,$ conversions. Note also that if $\rm\, m = n^k\,$ then the conversion is trivially achieved by partitioning into chunks of $\rm\,k\,$ digits.
A: To be honest the best way would be to just convert into base 10. Then subtract successive powers of the new base.
For example: 624_7 = 6*49 + 2*7 + 4 = 294 + 14 + 4 = 312 - 256 = 56 - 3*16 = 8
Therefore 624_7 = 138_16.
