The value of gravity changes as we move away from or towards the centre of the Earth.
This is given by: gR=GMR2, where M is the mass of a planet of radius R
So, M=43πR3ρ ; substituting in above equation
⇒gR=G43πρ×R
Since we want the value of g at depth(d) from the Earth's surface, we replace R by (R−d)
⇒gd=G43πρ×(R−d)
⇒gRgd=RR−d
⇒gdgR=(1−dR)