We present radiation-magneto-hydrodynamic simulations of star formation in self-gravitating , turbulent molecular clouds , modeling the formation of individual massive stars , including their UV radiation feedback . The set of simulations have cloud masses between m _ { \mathrm { gas } } = 10 ^ { 3 } M _ { \mathrm { \odot } } to 3 \times 10 ^ { 5 } M _ { \mathrm { \odot } } and gas densities typical of clouds in the local universe ( \overline { n } _ { \mathrm { gas } } \sim 1.8 \times 10 ^ { 2 } cm ^ { -3 } ) and 10 \times and 100 \times denser , expected to exist in high-redshift galaxies . The main results are : i ) The observed Salpeter power-law slope and normalisation of the stellar initial mass function at the high-mass end can be reproduced if we assume that each star-forming gas clump ( sink particle ) fragments into stars producing on average a maximum stellar mass about 40 \% of the mass of the sink particle , while the remaining 60 \% is distributed into smaller mass stars . Assuming that the sinks fragment according to a power-law mass function flatter than Salpeter , with log-slope 0.8 , satisfy this empirical prescription . ii ) The star formation law that best describes our set of simulation is d \rho _ { \mathrm { * } } / dt \propto \rho _ { \mathrm { gas } } ^ { 1.5 } if \overline { n } _ { \mathrm { gas } } < n _ { \mathrm { cri } } \approx 10 ^ { 3 } cm ^ { -3 } , and d \rho _ { \mathrm { * } } / dt \propto \rho _ { \mathrm { gas } } ^ { 2.5 } otherwise . The duration of the star formation episode is roughly 6 cloud ’ s sound crossing times ( with c _ { \mathrm { s } } = 10 km/s ) . iii ) The total star formation efficiency in the cloud is f _ { \mathrm { * } } = 2 \% ( m _ { \mathrm { gas } } / 10 ^ { 4 } \leavevmode \nobreak M _ { \mathrm { % \odot } } ) ^ { 0.4 } ( 1 + \overline { n } _ { \mathrm { gas } } / n _ { \mathrm { cri } } ) ^ { 0.91 } , for gas at solar metallicity , while for metallicity Z < 0.1 Z _ { \mathrm { \odot } } , based on our limited sample , f _ { \mathrm { * } } is reduced by a factor of \sim 5 . iv ) The most compact and massive clouds appear to form globular cluster progenitors , in the sense that star clusters remain gravitationally bound after the gas has been expelled .