  We discuss results from numerical simulations of star cluster formation in
the turbulent interstellar medium (ISM). The thermodynamic behavior of the
star-forming gas plays a crucial role in fragmentation and determines the
stellar mass function as well as the dynamic properties of the nascent stellar
cluster. This holds for star formation in molecular clouds in the solar
neighborhood as well as for the formation of the very first stars in the early
universe. The thermodynamic state of the ISM is a result of the balance between
heating and cooling processes, which in turn are determined by atomic and
molecular physics and by chemical abundances. Features in the effective
equation of state of the gas, such as a transition from a cooling to a heating
regime, define a characteristic mass scale for fragmentation and so set the
peak of the initial mass function of stars (IMF). As it is based on fundamental
physical quantities and constants, this is an attractive approach to explain
the apparent universality of the IMF in the solar neighborhood as well as the
transition from purely primordial high-mass star formation to the more normal
low-mass mode observed today.
