Barrett reduction
In modular arithmetic, Barrett reduction is an algorithm designed to optimize the calculation of a mod n {\displaystyle a\,{\bmod {\,}}n\,} without needing a fast division algorithm. It replaces divisions with multiplications, and can be used when n {\displaystyle n} is constant and a < n 2 {\displaystyle a<n^{2}} .