Understanding the Remainder
When you divide one integer by another, the result may not be a whole number. The remainder is what is "left over" after performing integer division. The relationship between dividend, divisor, quotient, and remainder is expressed by the Division Algorithm.
The Division Algorithm
Division Algorithm
For integers a (dividend) and d (divisor, d != 0), there exist unique integers q and r such that:
Modulo Operation
The remainder is also known as the modulo operation in programming.
Verification
Always verify: quotient times divisor plus remainder must equal the dividend.
Handling Negative Numbers
When dealing with negative dividends or divisors, conventions may vary. In mathematics, the remainder is typically defined to be non-negative (0 ≤ r < |d|). In most programming languages, the sign of the remainder follows the sign of the dividend. This calculator uses the truncated division convention (matching JavaScript's % operator), where the quotient is truncated toward zero.
Practical Applications
- Clock arithmetic: 15:00 in 12-hour format is 15 mod 12 = 3 PM.
- Checking divisibility: a number is divisible by d if the remainder is 0.
- Hash functions in computer science use modular arithmetic.
- Cyclic patterns: determining which day of the week a date falls on.
- Distributing items evenly and finding leftovers.
Examples
- 47 / 5 = 9 remainder 2 (because 9 x 5 + 2 = 47)
- 100 / 7 = 14 remainder 2 (because 14 x 7 + 2 = 100)
- -17 / 3 = -5 remainder -2 (truncated division: -5 x 3 + (-2) = -17)