How do you know that? Last I read, there was not even any particularly prevalent theory about why Mercury and Venus have no moons. So unless there’s something new, I don’t think it’s true that they there is any reason they could not have moons given their distance from the sun. They just happen not to (and/or it may be something to do with the presumed increased traffic closer to the sun having been more likely to disrupt moons closer in). So, no formula.