  The generating function of a Hamiltonian $H$ is defined as $F(t)=\langle
e^{-itH}\rangle$, where $t$ is the time and where the expectation value is
taken on a given initial quantum state. This function gives access to the
different moments of the Hamiltonian $\langle H^{K}\rangle$ at various orders
$K$. With the constraint of minimizing the quantum resources needed on
near-term quantum computers, we show that the evaluation of the generating
function can be made with only one extra ancillary qubit. Due to the limited
stability of actual quantum devices, the function $F(t)$ can a priori be
estimated on a restricted time interval limiting automatically the orders of
the moments that could be computed. Despite of this current limitation and even
with a small number of moments, a post-processing on classical computers can be
used to predict approximate ground or excited state energies and/or approximate
long-time evolutions. This post-processing can be achieved using methods based
on the Krylov space and/or on the $t$-expansion approach that is based on
imaginary time evolution. Hybrid quantum-classical calculations are illustrated
in many-body interacting systems using the pairing and Fermi-Hubbard models.
Possible extensions using symmetry breaking and restoration as well as a
multi-reference framework are discussed.
