In this paper, we calculate the explicit expression for the fugacity for two-and three-dimensional weakly interacting Bose and Fermi gases from their equations of state in isochoric and isobaric processes, respectively, based on the mathematical result of the boundary problem of analytic functions -the homogeneous Riemann-Hilbert problem. We also discuss the Bose-Einstein condensation phase transition of three-dimensional hard-sphere Bose gases.