Implement the computation of the momentum recursively