This is how we get earthquake . There are two wave,first is compassional waves(called P-waves),second is shear waves(called S-waves)
The formula originally used by Richter is:
(Where
However,these formules are not 100 percent accurate ,It depends on different areas and stations.This is just a estimation based on varying data.
Nowadays,the earthquake is happening more and more frquently.Although human created some formulas to estimate it ,natural power is infinite.Do not destroy our earth any more!