Recall how we found the continued fraction for a rational.
We used the division algorithm to determine the terms in the continued fraction. Here's a recap:
By the division algorithm, we have these unique equations:
a=bq1+r1
b=r1q2+r2
r1=r2q3+r3
⋮
rn−2=rn−1qn+0
Then, we can rearrange each of them so that we have what we want:
a=bq1+r1⟹ba=q1+br1
b=r1q2+r2⟹r1b=q2+r1r2
r1=r2q3+r3⟹r2r1=q3+r2r3
⋮⋮
rn−2=rn−1qn+0⟹rn−1rn−2=qn+0.
Now, it's time to substitute repeatedly.
ba=q1+q2+r1r21=q1+q2+q3+r2r311⋮=q1+q2+⋱+qn111=[q1,q2,⋯,qn].
Since all the quotients when we used the division algorithm were unique, we know the continued fraction expansion is as well, because we used those unique values.
Note: If we have a fraction of the form [a1,a2,⋯,an−1,2], then note that this is equal to [a1,a2,⋯,an−1,1,1]. We are not able to get the second representation from the division algorithm though.