mod

Modulo Calculator

The remainder of a division, both as most programming languages give it and as mathematicians define it.

Math & AlgebraRuns in your browser

Result…

 

…

How it's calculated

a mod n = a − n × q,  q chosen so that 0 ≤ r < |n|  (Euclidean)
For n > 0: q = ⌊a / n⌋

For negative numbers, languages differ: JavaScript and C keep the sign of a (−7 % 3 = −1), while mathematics gives a result between 0 and |n| − 1 (−7 mod 3 = 2).

Your numbers, step by step

    More in Math & Algebra