The distribution of protostar masses is studied for core-environment systems whose duration of infall follows a waiting-time distribution. Each core-environment system has a continuous density profile with no barrier to mass flow. The core is an isothermal sphere and the environment is a filament, a layer, or a uniform medium. The infall is terminated by gas dispersal due to outflows and turbulence. The distribution of infall durations is a declining exponential, the simplest waiting-time distribution. The resulting distribution of protostar masses closely resembles the initial mass function, provided the environment density is sufficiently high, and the distribution of initial core masses is sufficiently narrow. The high-mass tail of the mass function increases strongly with environment density and weakly with environment dimension. "Isolated" regions of low environment density form protostars of low mass from within the parent core. In contrast, "clustered" regions of high environment density form protostars of low mass from core gas, and protostars of high mass from core and environment gas.