Formulas: (pick one)

driven=(drive*diff)/(speedo/(inches/(PI*diam)))
driven=(drive*diff)/(speedo/(inches/c))
driven=(drive*diff)/(speedo/revs)

driventeeth on speedo driven gear (changeable, this is the new part you need to order)
driveteeth on t-case speedo drive gear (fixed, 13 on D20/D300/NV200, try 4 for D18)
diffrear diff ratio (like 3.31, 3.73, 4.10, 4.56, 4.88, etc...)
speedorevs speedo wants per mile (normally 1000 on late CJ)
inchesconstant value, inches=63360 (inches in a mile)
diamtire's actual diameter, in inches (twice rolling radius)
PIconstant value, PI=3.14159...
ctire's actual circumference rolling on the ground, in inches
revstire's actual revs per mile

Notes/Tips:
To be exact, use the true tire size not what it says on the tire. (a 32x11.50R15 tire can be 30" to 32" in diameter)
Mark a starting point on your tire and on a flat level road. Run exactly 3 revs of your tire (about 20 to 30 feet) measure the distance from start to finish. Then divide by 3 for your average inches per full rev., which is the rolling circumference of your tire.
You should have a normal load of people an equipment. Normally 500 to 700 lbs. and set your tire to the normal highway pressure. Note that pressure will affect the size (circumference) of the tire.
As your tires ware down your rolling circumference will decrease a bit. About up to 3% depending on tire size and tread depth. (decreasing diameter and circumference, increasing revs per mile...increasing the number of teeth on your required gear)


Other good speedo sites: