Plumb all the things you know into the calculator- motor, voltage, diff ratio etc, then experiment with the spur/pinion ratios until you hit the magic 40mph mark I reckon. Bear in mind the maxx speed you want to run the motor at is 40,000 rpm or there abouts.