Solution (source code)

= Solution

Build a solid uniform sphere from thin shells: $dC=(2/3)r^2(4\pi\rho r^2dr)$. <Integration> gives $C=8\pi\rho R^5/15$, while $M=4\pi\rho R^3/3$. Hence $\boxed{C=2MR^2/5}$. This is a spherical uniform-density model; planetary flattening modifies the exact relation.