We simulate the formation and evolution of young star clusters using the combination of smoothed-particle hydrodynamical ( SPH ) simulations and direct N -body simulations . We start by performing SPH simulations of the giant molecular cloud with a turbulent velocity field , a mass of 4 \times 10 ^ { 4 } to 5 \times 10 ^ { 6 } M _ { \odot } , and a density between \rho \sim 1.7 \times 10 ^ { 3 } and 170 { cm } ^ { -3 } . We continue the hydrodynamical simulations for a free-fall time scale ( t _ { ff } \simeq 0.83 Myr and 2.5 Myr ) , and analyze the resulting structure of the collapsed cloud . We subsequently replace a density-selected subset of SPH particles with stars by adopting a local star-formation efficiency proportional to \rho ^ { 1 / 2 } . As a consequence , the local star formation efficiency exceeds 30 per cent , whereas globally only a few per cent of the gas is converted to stars . The stellar distribution by the time gas is converted to stars is very clumpy , with typically a dozen bound conglomerates that consist of 100 to 10 ^ { 4 } stars . We continue to evolve the stars dynamically using the collisional N -body method , which accurately treats all pairwise interactions , stellar collisions and stellar evolution . We analyze the results of the N -body simulations when the stars have an age of 2 Myr and 10 Myr . During the dynamical simulations , massive clusters grow via hierarchical merging of smaller clusters . The shape of the cluster mass function that originates from an individual molecular cloud is consistent with a Schechter function with a power-law slope of \beta = -1.73 at 2 Myr and \beta = -1.67 at 10 Myr , which fits to observed cluster mass function of the Carina region . The superposition of mass functions have a power-law slope of { \raise - 2.15 pt \hbox { $ \buildrel < \over { \sim } $ } } -2 , which fits the observed mass function of star clusters in the Milky Way , M31 and M83 . We further find that the mass of the most massive cluster formed in a single molecular cloud with a mass of M _ { g } scales with 6.1 M _ { g } ^ { 0.51 } which also agrees with recent observation of the GMC and young clusters in M51 .