By newton’s law of motion, the force due to gravity on a body of mass m on it’s surface will be
F = mass × acceleration due to gravity
or F = mg [Equation 1]
By Newton’s gravitational law, this attractive force is given by
F = {GMm\over R^2} [Equation 2]
From eqn. 1 and 2 we get,
mg = {GMm\over R^2}
⇒ acceleration due to gravity g = {GM\over R^2}