Skip to content
Local

Study

Modulo Calculator

Work out a mod n and the remainder, with the whole-number quotient and the working, exact for huge numbers, negatives and decimals.

Runs in your browser. Nothing leaves this device.

How to use Modulo Calculator

  1. 1Type the number to divide (a) and the number to divide by (n).
  2. 2Read a mod n, the quotient and the line of working.
  3. 3For negative numbers, compare the three answers that different languages give.

Questions

Why are there different answers for negative numbers?

They agree when both numbers are positive. With a negative number, Python and Excel round the quotient down, so the result takes the sign of n. C, Java and JavaScript round toward zero, so the remainder takes the sign of a. The Euclidean answer is never negative.

What is -7 mod 3?

It is 2, because -7 = 3 × (-3) + 2. The % operator in C, Java and JavaScript gives -1 instead, because -7 = 3 × (-2) + (-1).

Does it work with very large numbers and decimals?

Yes. It uses exact whole-number arithmetic with no size limit, and decimals like 5.5 mod 2 are worked out exactly too.

Are my numbers sent anywhere?

No. Everything is worked out in your browser.

Is it free?

Yes. No account, no watermark and no daily limit.

Esc