To express the base $10$ number $5213$ in base $7$, all I have to do is simply divide by $7$ as follows:
$5213 \div7=744$ with remainder $5$
$744\div 7=106$ with remainder $2$
$106\div7=15$ with remainder $1$
$15 \div7=2$ with remainder $1$
Hence $5213$ in base $7$ is $21125$.
Now the formula for this operation is as follows:
$N=a_nr^n+a_{n-1}r^{n-1}+...+a_2r^2+a_1r+a_0$ where $N$ be the given number, and $r$ the radix of the proposed base.
To find the values $a_0,a_1,a_2...a_n$, divide $N$ by $r$, then the remainder is $a_0$, and the quotient is:
$a_nr^{n-1}+a_{n-1}r^{n-2}+...+a_2r+a_1$
Then continue the operation until all required digits have been acquired.
My question is if you divide $N$ by $r$, then the formula becomes thus:
$\dfrac{N}{r}=a_nr^{n-1}+a_{n-1}r^{n-2}+...+a_2r+a_1+\dfrac{a_0}{r}$ and obviously the remainder is not simply $a_0$ but rather $\dfrac{a_0}{r}$. But in the above calculation with $5213$ the remainder is $a_0$, so I'm confused about what's going on here.
We have
$$N = a_n r^n + \ldots + a_1 r^1 + a_0 = A_1 r + a_0$$
Which gives us that the remainder when dividing $N$ by $r$ is $a_0$. Then, we remove that remainder from $N$ and then divide by $r$ (knowing that what we get will still be an integer):
$$\begin{eqnarray} \frac{N - a_0}{r} & = & \frac{A_1 r}{r} \\ & = & A_1 \\ & = & a_n r^{n-1} + \ldots + a_1 & = & A_2 r + a_1 \end{eqnarray}$$
For example, when you convert $5213$ into base $7$ what's happening is the following:
$$\begin{eqnarray} 5213 & = & \square \times 7 + 5 \\ (5213 - 5) \div 7 & = & 744 \\ & = & \square \times 7 + 2 \\ (744 - 2) \div 7 & = & 106 \\ & = & \square \times 7 + 1 \end{eqnarray}$$
and so on.