The speed of sound in air depends on temperature and follows v = 331.5 + 0.6 t, with t in degrees Celsius: each degree adds about 0.6 m/s. Given the time the sound took to arrive, the distance to its source is also shown.
Sound travels through air at a speed that depends on the temperature. Warmer air has faster-moving molecules, and the disturbance passes along more quickly.
Here is the air temperature in degrees Celsius and the speed in metres per second. At 0 °C sound travels at 331.5 m/s, and each degree adds roughly 0.6 m/s.
Time the gap between the flash and the thunder, multiply by the speed of sound, and you have the distance. Light covers seven and a half times the circumference of the Earth in a second, so its travel time can be ignored entirely.
At 15 °C the speed of sound is 340.5 m/s, which is 1225.8 km/h.
If thunder arrives three seconds after the flash, the strike was 340.5 × 3 = 1021.5 m away, a little over a kilometre.
The linear formula is an approximation. Strictly the speed goes as the square root of the absolute temperature, . Between 0 °C and 30 °C the two differ by about 0.3 m/s, which never matters in practice. This calculator accepts temperatures from −50 °C to 50 °C, beyond which the approximation drifts too far to be worth giving.
Humidity shifts the figure slightly, damp air carrying sound a little faster. Air pressure on its own has almost no effect.