An analytic formula to calculate the reheating temperature via gravitational particle production