calculator.onl
Categories50

Euclidean modulo calculator

Find the nonnegative remainder and floor quotient for integer division by a positive modulus.

A worked example

Find −1 and 1 on the wheel of remainders modulo 5.

Euclidean remainder3Floor quotient-4Positive modulus m5
Signed whole integer a, with no decimal point or grouping separators.

Strictly positive whole integer m.

Updates as you type

Enter integers with at most 80 digits. The modulus must be positive.

YOUR RESULT

Euclidean remainder

3

Calculated from your inputs

Floor quotient-4
Positive modulus m5
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

Find the nonnegative remainder and floor quotient for integer division by a positive modulus. Enter your values and inspect the calculation details. For a related calculation, try GCD & LCM Calculator for Multiple Numbers.

What to enter

InputWhat it meansExample value
Integer dividend aSigned whole integer a, with no decimal point or grouping separators.-17
Positive modulus mStrictly positive whole integer m.5

How the calculation works

  1. Take q = floor(a/m).
  2. Calculate r = a − qm; this guarantees 0 ≤ r < m.
  3. Verify the exact identity a = qm + r and inspect the remainder within one modulus interval.
The formulaa = qm + r; q = floor(a/m); 0 ≤ r < m; m > 0

A worked example

Worked example: −17 = (−4) × 5 + 3, so the remainder is 3.

Example you can load

What to enter
Result for this example · Euclidean remainder3

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

Each integer may contain at most 80 digits. The modulus must be positive. This is Euclidean modulo, which can differ from a programming language’s signed remainder operator.

Frequently asked questions

Why is −17 modulo 5 equal to 3?

The floor quotient is −4, so −17 = (−4) × 5 + 3.

Can the modulus be negative or zero?

No. This tool uses the positive-modulus Euclidean convention.

Is this the same as the % operator?

Not in every language. Some operators use truncation and return a negative remainder for negative dividends.