Solution (source code)

= Solution

Successive term magnitudes have ratio $(n+1)/x$, so truncate near the least term, $n\simeq x-1$. Stirling gives least relative term $\sqrt{2\pi x}e^{-x}$, hence an exponentially small relative remainder of that order.