Compute multiple modular inverses with Montgomery's trick (opens in new tab)
Montgomery's trick is an algorithm for computing multiple inverses modulo the same prime in less time than it would take to compute each inverse individually.
Read the original article