Show that $\lim_{n \to \infty} \left(1+\frac{a_n}{n}\right)^n= e^a$ when $a_n \to a$ I have seen a proof that shows
$$\lim_{n\to\infty} \left(1+\frac{x}{n}\right)^n = e^x$$
by looking at the Taylor series expansion of $\ln(1+x)$ at $x=0$.
To prove a theorem, my textbook uses the fact
$$\lim_{n \to \infty} \left(1+\frac{a_n}{n}\right)^n = e^a$$
when $a_n \to a$.
How can I prove this?

Write$\left(1+\cfrac{a_n}{n}\right)^n$ as
$\left(\left(1+\cfrac{a_n}{n}\right)^{\cfrac{n}{a_n}}\right)^{\large{a_n}}$.
We know $\lim_{u\to \infty}\left(1+\dfrac1u\right)^u=e$. therefor $\lim_{n\to \infty}\left(1+\cfrac{a_n}{n}\right)^{\dfrac{n}{a_n}}=e$. and the original limit equal to $e^a$
Edit: As @DannyPak-KeungChan mentioned it is possible that value of $a$ be equal to $0$. in this case we should plug in this value in the original limit to get $\lim_{n \to \infty} \left(1+\frac{0}{n}\right)^n = 1=e^0$.
