  We study the effects of the local environment on the molecular gas content of
a large sample of log($M_{*}$/$M_{\odot}$) $\gtrsim$ 10 star-forming and
starburst galaxies with specific star-formation rates (sSFRs) on and above the
main sequence (MS) to $z$ $\sim$ 3.5. ALMA observations of the dust continuum
in the COSMOS field are used to estimate molecular gas masses at $z$ $\approx$
0.5-3.5. We also use a local universe sample from the ALFALFA HI survey after
converting it into molecular masses. The molecular mass ($M_{ISM}$) scaling
relation shows a dependence on $z$, $M_{*}$, and sSFR relative to the MS, but
no dependence on environmental overdensity $\Delta$ ($M_{ISM}$ $\propto$
$\Delta^{0.03}$). Similarly, gas mass fraction (f$_{gas}$) and depletion
timescale ($\tau$) show no environmental dependence to $z$ $\sim$ 3.5. At
$\langle z\rangle$ $\sim$ 1.8, the average $\langle
M_{ISM}\rangle$,$\langle$f$_{gas}\rangle$, and $\langle \tau \rangle$ in
densest regions is (1.6$\pm$0.2)$\times$10$^{11}$ $M_{\odot}$, 55$\pm$2%, and
0.8$\pm$0.1 Gyr, respectively, similar to those in the lowest density bin.
Independent of the environment, f$_{gas}$ decreases and $\tau$ increases with
increasing cosmic time. Cosmic molecular mass density ($\rho$) in the lowest
density bins peaks at $z$ $\sim$ 1-2, and this peak happens at $z$ $<$ 1 in
densest bins. This differential evolution of $\rho$ across environments is
likely due to the growth of the large-scale structure with cosmic time. Our
results suggest that the molecular gas content and the subsequent
star-formation activity of log($M_{*}$/$M_{\odot}$) $\gtrsim$ 10 star-forming
and starburst galaxies is primarily driven by internal processes, and not by
their local environment since $z$ $\sim$ 3.5.
