Solution (source code)

= Solution

The weak-damping <mechanical energy> is proportional to the squared oscillation amplitude, so it decays as $e^{-\gamma t}$. Over one period $P=2\pi/\omega_d$, the fractional loss is $1-e^{-\gamma P}\simeq\gamma P$. Hence
$$
\boxed{\frac{E}{\Delta E}\simeq\frac1{\gamma P}
\simeq\frac{\omega_0}{2\pi\gamma}.}
$$
For the release-from-rest solution, comparison at successive corresponding turning points gives the more precise ratio $E/\Delta E=(1-e^{-\gamma P})^{-1}$. The <quality factor> is $Q\simeq2\pi E/\Delta E=\omega_0/\gamma$; the requested energy-to-loss ratio itself has the extra factor $1/(2\pi)$.