Solution (source code)

= Solution

Inside the <generating functional>, multiplication by a field can be replaced by a <functional derivative> of the source factor:
$$
\phi(x)e^{i\int J\phi}=\frac1i\frac{\delta}{\delta J(x)}e^{i\int J\phi}
=-i\frac{\delta}{\delta J(x)}e^{i\int J\phi}.
$$
Expanding the interaction exponential, making this replacement in every term, and resumming gives
$$
\boxed{
Z_n[J]=\exp\!\left[-ig\frac{(-i)^n}{n!}
\int d^dx\,\frac{\delta^n}{\delta J(x)^n}\right]Z_0[J]}.
$$
This formal identity assumes a common regulator, a source-independent normalization, and permission to interchange the <path integral>, power series, and functional derivatives. A normalized functional with $Z_n[0]=1$ requires division by the same expression evaluated at $J=0$, which removes connected <Vacuum Feynman diagrams>.