Well, of course we can’t verify n =2 to infinite precision, but measurements haven’t confirmed any significant deviation from a 1/r[sup]2[/sup] law for electromagnetism. I don’t remember the limits; you’d have to check in Jackson or something like that, but it’s truly tiny.

For gravity, the situation is a little more complicated because of the weakness of the gravitational force relative to electromagnetism, which makes experiments harder to get high accuracy with. And in any event since Newtonian gravity isn’t exactly the same as GR, there are some deviations due to GR effects, at least when looking at celestial mechanics. Someone who’s studied this more recently than I is welcome to correct me if I’m wrong, but isn’t the perihelion precession of Mercury due to a 1/r[sup]4[/sup] term?

Actually, I find in my copy of Ohanian (not a great book, but oh well) that the limits are such that if we assumed a Yukawa form for the potential, classical deviations from inverse-square are on the same order for gravity and electromagnetism, which is to say there aren’t any.

If the E-M force behaves as inverse-square, a uniformly charged spherical shell produces an exactly zero electric field inside it. Zero is able to be measured with great precision, so using spherical shells, we know that for E-M, n = 2 to within one part in a billion (or so).

If the gravitational force behaves as inverse-square, a uniform-density shell would have a zero gravitational field inside it. This is not as easily measured, however.

With electromagnetism, in QED you can tie the inverse square law to the photon being massless and the limits on it are truly tiny: they’re of the order 10[sup]-27[/sup] eV, or 10[sup]-63[/sup] kg, so the indirect evidence is very strong. I seem to recall these limits derive from something to do with Jupiter’s magnetic field and signals from space probes.

There have been reports floating about for years that there might be some minor variation from n = 2 for gravity. Back in the 80’s, some physicists found discrepancies in the strength of gravity at the earths surface vs down a deep mine shaft. This was briefly hailed as evidence of a “fifth force” The effects were ultimately dismissed as being within the range of experimental error.
More recently, the Pioneer spacecraft have been shown to be slowing a little bit faster than they should be according to the standard calculations of the gravitational force. This EarthFiles article: Mysterious Slowing of Pioneer Spacecraft gives a fairly decent overview of the situation.