# Finite continued fraction with dots in-between

I found this link on how to typeset continued fractions. The form I want is the following: with dots in between as illustrated. Thanks in advance.

\documentclass{article}
\usepackage{stackengine,amsmath}
\stackMath
\begin{document}
$a_0 + \frac{1\kern6em}{\displaystyle a_1 + \frac{1\kern5em}{\displaystyle a_2 +\stackunder{}{\ddots\stackunder{}{\displaystyle {}+ \frac{1}{\displaystyle a_{n-1} + \frac{1}{a_n}}} }}}$
\end{document}