Gravity outside and inside a sphere

A uniform spherical shell pulls an outside mass as if all its mass sat at its centre and pulls a mass inside it not at all, so outside a uniform planet $g = \frac{GM}{r^2}$ while inside only the mass nearer the centre counts and $g = \frac{GMr}{R^3}$ grows in proportion to $r$.

From Physics 1.