Skip to content
NexUnit home
EnglishEspañol

Modulo Calculator

Find a mod n — the remainder after division — with both the math (always positive) and programming conventions.

a mod n

2

Truncated remainder (a % n in code)
-1
Integer quotient
-3

Show the work

  1. Divide, then round down

    q = ⌊a ÷ n⌋

    ⌊(−7) ÷ 3⌋ = −3

  2. Take away n × q

    a mod n = a − n × q

    (−7) − 3 × (−3) = 2

Want this on your site? Embed the modulo calculator.