dopecalc

Modulo Calculator

Compute the quotient and remainder when dividing two integers. Displays the division identity a = q × b + r, along with floor division, truncated division, and the modulo (%) result.

About this Calculator

Compute the quotient and remainder when dividing two integers. Displays the division identity a = q × b + r, along with floor division, truncated division, and the modulo (%) result.

Formula & Calculations

Formula

a = q × b + r, where q = floor(a/b) and 0 ≤ r < |b| (Euclidean division)
Where:
  • a=The dividend (number being divided)
  • b=The divisor (number dividing by; cannot be zero)
  • q=The quotient (integer result of floor division)
  • r=The remainder (0 ≤ r < |b|)

Assumptions

  • The divisor (b) must not be zero.
  • Input numbers should be integers.
  • Uses Euclidean division where the remainder is always non-negative.

Calculation Examples

Example 1

Inputs:a = 17, b = 5
Result:17 = 3 × 5 + 2, Quotient = 3, Remainder = 2

17 ÷ 5 = 3 remainder 2. Check: 3 × 5 + 2 = 15 + 2 = 17.

Example 2

Inputs:a = -17, b = 5
Result:-17 = -4 × 5 + 3, Quotient = -4, Remainder = 3

With Euclidean division, -17/5 = -4 remainder 3. Check: -4 × 5 + 3 = -20 + 3 = -17.

Frequently Asked Questions

What is the difference between modulo and remainder?

In mathematics, the modulo operation returns a non-negative result (Euclidean definition). In many programming languages (including JavaScript), the % operator returns a remainder that takes the sign of the dividend. This calculator shows both for clarity.

What is the division algorithm?

The division algorithm states that for any integers a and b (b ≠ 0), there exist unique integers q (quotient) and r (remainder) such that a = q×b + r and 0 ≤ r < |b|.