Effect of beam energy straggling on resonant yield in thin gas targets: The cases 22Ne(p, γ)23Na and 14N(p, γ)15O