Quotient Remainder Theorem states that for any pair of integers a and b (b is positive), there exists two unique integers q and r such that:
a = b x q + r
where 0 <= r < b
If a = 22, b = 4
then q = 5, r = 2
22 = 4 x 5 + 2
If a = -19, b = 5
then q = -4, r = 1
-19 = 5 x -4 + 1
Use of Quotient Remainder Theorem:
Quotient remainder theorem is the fundamental theorem in modular arithmetic. It is used to prove Modular Addition, Modular Multiplication and many more principles in modular arithmetic.
To prove Quotient Remainder theorem, we have to prove two things:
For any integer a and positive integer b:
1. q and r exist
2. q and r are unique
Existence of q and r:
Consider the progression …, a – 3b, a – 2b, a – b, a, a + b, a + 2b, a + 3b…
This extends in both directions.
By the Well-Ordering Principle, there must exist a smallest non-negative element x.
Thus, x = a – qb and x must be in the interval [0, b) because otherwise r-b would be smaller than r and a non-negative element in the progression.
Uniqueness of q and r:
Suppose we have another pair q0 and r0 such that a =b x q0 + r0, with 0 <= r0 < b.
b x q + r = b x q0 + r0
We see that r – r0 = b(q0 – q), and so q0 – q = b / (r – r0)
Since 0 <= r < b and 0 <= r0 < b, we have that -b < r-r0 < b
Hence, r- r0 = 0 that implies r = r0
So r – r0 = 0 = b(q0 – q)
which implies that q = q0.
This shows uniqueness.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.