Long Division with Remainder
For decimal numbers (e.g. 112.45 ÷ 56.7), use : Decimal division.
For polynomials, e.g. (x2 + 1) ÷ (x - 1), use : Polynomial euclidean division.
Answer
Remainder = 0
Long division
0 | 1 | 8 | |
7 | 1 | 2 | 6 |
1 | |||
- | 0 | ||
1 | 2 | ||
- | 7 | ||
5 | 6 | ||
- | 5 | 6 | |
0 |
Euclidean division of two positive integers
Doing the integer division of a positive integer (the dividend) by another non-zero positive integer (the divisor) consists on finding two integers called the quotient and the remainder that verifies the equality,
dividend = (quotient × divisor) + remainder
the remainder is an integer less than the divisor.
Example:
17 ÷ 5 = 3 remainder 2
Euclidean division of two relative integers
The above definition can be generalized to two integers that might be positive or negative (relative integers).
If a is the the dividend and b the divisor,
then there exist unique two integers q (quotient) and r (remainder) such that,
`a = b. q + r` and `0 <= r < |b|`
Examples
- Case of positive integers:
23 ÷ 4 = 5 remainder 3
56 ÷ 7 = 8 remainder 0
- Cases of relative integers
-23 ÷ 5 = -5 remainder 2
-65 ÷ 3 = -22 remainder 1
45 ÷ -4 = -11 remainder 1
-26 ÷ -7 = 4 remainder 2
- Special cases:
If the dividend is 0 then the quotient and the remainder are equal to 0.
0 ÷ 3 = 0 remainder 0
If the dividend is equal to the dividend then the quotient is equal to 1 and the remainder is 0.
24 ÷ 24 = 1 remainder 0
If the dividend is a multiple of the dividend then the remainder is equal to 0.
9 ÷ 3 = 3 remainder 0
Integer division and modulo
For two given integers a and b, the remainder of the Euclidean division of a by b is congruent to a modulo b,
`a\equiv r\mod b`
r being the remainder of the Euclidean division of a by b.
Programming
Here is a program that computes the quotient and the remainder of the Euclidean division of two integer numbers a (dividend) and b (divisor).
Note that in python, the remainder of the integer division may be negative.
In the above calculator, the remainder is always positive (or zero) which guarantees its uniqueness.
Python
def euclidean_division(a, b):
#quotient = a//b, remainder = a % b
return (a//b, a%b)
See also
Long decimal Division
Long Addition
Long Subtraction
Long Multiplication
Modulo operation
Divisibility rules
Divisibility Test