Long Division with Remainder

Calculates the long division of two integer numbers with a remainder. Numbers may be positive, negative or powers of integers (Example : input 2^45 for 2 to the power of 45). The detailed long division is done when the dividend and the divisor are positive integers.
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

Quotient = 18

Remainder = 0

Long division
018
7126
1
-0
12
-7
56
-56
0
Do you have any suggestions to improve this page ?


This tool calculates the Long division of two integers of positive or negative sign. The dividend and the divisor may be powers of an integer (e.g 2^43 ÷ 67). Enter two integers to calculate the quotient and the remainder of their integer division. Example: 15/2 = 7 (quotient), remainder=1.

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