Calculate $f^{(n)}(0)$ where $f(x) = e^{x^2}$ The problem is stated as:

Calculate $f^{(n)}(0)$ where $f(x) = e^{x^2}$ and $n \in \mathbb{N}$

Attempt:
We know that $e^{x} = \sum_{k=0}^{n} \frac{1}{k!}x^k +\frac{x^{n+1}e^{\theta x}}{(n+1)!}$ for some $\theta = \theta (x) \in (0,1)$
Hence, $e^{x^2}=\sum_{k=0}^{n} \frac{1}{k!}x^{2k} +\frac{x^{2n+1}e^{\theta x^2}}{(n+1)!}$
Comparing terms with the general Maclaurin polynomial, we get that:
$\frac{1}{k!}x^{2k} = \frac{f^{(n)}(0)}{n!}x^{n}$
First, we have to equate the exponent of the $x$ - terms, so $2k = n \iff k = n/2$
Therefore, we have that:
$\Rightarrow f^{n}(0) = \frac{n!}{(n/2)!}$
However, since we had natural numbers in our expression, I wonder what would happen if $n$ was odd in this case. How could I generalize this even further?
Thanks!

We have
\begin{align*}
e^{x^2}&=\sum_{k=0}^\infty \frac{(x^2)^k}{k!}\\
&=\frac{x^0}{0!}+\frac{x^2}{1!}+\frac{x^4}{2!}+\frac{x^6}{3!}+\dots\\
&=\frac{x^0}{0!}+0\frac{x^1}{1!}+2!\frac{x^2}{2!}+0\frac{x^3}{3!}+\frac{4!}{2!}\frac{x^4}{4!}+0\frac{x^5}{5!}+\frac{6!}{3!}\frac{x^6}{6!}+\dots\\
\end{align*}
So,
$$e^{x^2}=\sum_{k=0}^\infty a_k\frac{x^k}{k!},$$
where
\begin{align*}
a_k=\begin{cases}
\frac{k!}{(k/2)!}&\text{if $k$ is even}\\
0&\text{if $k$ is odd}
\end{cases}
\end{align*}
