Proof:The quotient and remainder are unique

From CS2800 wiki

In order to justify calling quotients and remainders "the quotient" or "the remainder", we should check that they are unique. This is justified by the following claim:

For any [math]a \href{/cs2800/wiki/index.php/%E2%88%88}{∈} \href{/cs2800/wiki/index.php/%E2%84%A4}{ℤ} [/math] and [math]b \neq 0 \href{/cs2800/wiki/index.php/%E2%88%88}{∈} \href{/cs2800/wiki/index.php/%E2%84%A4}{ℤ} [/math], if [math]q [/math] and [math]r [/math] are a quotient and remainder of [math]a [/math] and [math]b [/math] (that is, if [math]a = qb + r [/math] and [math]0 \leq r \lt b [/math]), and if [math]q' [/math] and [math]r' [/math] are also a quotient and remainder of [math]a [/math] over [math]b [/math], then [math]q = q' [/math] and [math]r = r' [/math].
Proof:
Assume that [math]a = qb + r [/math] and [math]a = q'b + r' [/math] and that both [math]r [/math] and [math]r' [/math] are between 0 and [math]b-1 [/math]. We want to show that [math]q = q' [/math] and [math]r = r' [/math].

We have [math]qb + r = a = q'b + r' [/math], so [math](r - r') = (q' - q)b [/math]. This means that [math]r - r' [/math] is a multiple of [math]b [/math]; it could be any of [math]\dots, -2b, -b, 0, b, 2b, \dots [/math]. However, since we have [math]0 \leq r \lt b [/math] and [math]0 \leq r' \lt b [/math], we have [math]-b \lt r - r' \lt b [/math]. Thus, the only possible value of [math]r - r' [/math] is 0, so [math]r = r' [/math].

Plugging this back in to the equation [math]0 = r - r' = (q - q')b [/math] shows that either [math]q - q' = 0 [/math] or [math]b = 0 [/math]. Since we have defined the quotient and remainder by [math]b [/math], we must have [math]b \neq 0 [/math], so [math]q - q' = 0 [/math] and thus [math]q = q' [/math].