Solution (source code)

= Solution

For a low <circular orbit>, <Newton's law of universal gravitation> gives $P=2\pi\sqrt{R^3/(GM)}$. Using $M=4\pi\bar\rho R^3/3$ yields
$$
\boxed{P^2=\frac{3\pi}{G\bar\rho}.}
$$
Thus \b[the Moon and Mars have roughly comparable <mean densities>]: <low circular-orbit period measures mean density>. Equal periods would mean equal <mean densities> in this approximation. This does not require their masses or <radii> to be similar. The orbit altitudes must be small compared with the body <radii>, and the bodies are being treated as approximately spherical.