How does one come up with a Continued Fraction?

Note we have Euler's continued fraction formula, which states:

$$a_{0}+a_{0}a_{1}+a_{0}a_{1}a_{2}+\cdots +a_{0}a_{1}a_{2}\cdots a_{n}\\=\cfrac {a_{0}}{1-{\cfrac {a_{1}}{1+a_{1}-{\cfrac {a_{2}}{1+a_{2}-{\cfrac {\ddots }{\ddots {\cfrac {a_{{n-1}}}{1+a_{{n-1}}-{\cfrac {a_{n}}{1+a_{n}}}}}}}}}}}}$$

This may easily be proven by induction and lends itself for easy conversion of a series into a fraction. For example, we know that:

$$\arctan(x)=\sum_{n=0}^\infty\frac{(-2)^nx^{2n+1}}{2n+1}$$

Set $a_0=x$ and inductively,

$$a_{n+1}=\frac{(-1)^{n+1}x^{2n+3}}{2n+3}\prod_{k=0}^n(a_k)^{-1}=-\frac{2n+1}{2n+3}x^2$$

And then after some algebra, you'll be able to derive

$$\arctan(x)=\cfrac{x}{1+\cfrac{x^2}{3+\cfrac{4x^2}{5+\cfrac{9x^2}{7+\ddots}}}}$$

Plug $x=1$ in and do some more algebra and you'll end up with the formula for $\pi$.