Integer Arithmetic

1. Division Algorithm


(Def)
Let $a, b\in Z$ and $b \ne 0$.
$b \mid a$ if $\exists \in Z$ s.t. $a = bc$ and
$b \nmid a$ otherwise.


(Division Algorithm)
For $a, n \in Z$ and $n > 0$, $\exists!q, r \in Z$ s.t. $a = n \times q + r, 0 \leq r \le n.$
If $r = 0$, then $n \mid a$.


(Greatest Common Divisor)
(Def)
The greatest common divisor of a and b is the largest integer that can divide both integers.

(Note)
$ a = b \times q + r, 0 \leq r \le n$
Fact 1: $gcd(a, 0) = a$
Fact 2: $gcd(a, b) = gcd(b, r)$

2. Euclidean Algorithm

(Note)
When $gcd(a, b) = 1$, we say that a and b are relatively prime.

Example
Q : Find the greatest common divisor of 2740 and 1760.
A : 20

3. Extended Euclidean Algorithm

Given two integers $a$ and $b$, we often need to find other two integers, $s$ and $t$, such that

The extended Euclidean algorithm can calculate the $gcd(a, b)$ and at the same time calculate the value of $s$ and $t$.

Input : $a$, $b$
Output : $s$, $t$, $gcd(a, b)$ such that $as + bt = gcd(a, b)$

Considier
and in Euclidean Algorithm

Define

pf)

Suppose that

Example
Q : Given a = 161 and b = 28, find gcd (a, b) and the values of s and t.
A : $gcd (161, 28) = 7$, $s = −1$ and $t = 6$.

4. Linear Diophantine Equation

Given for ,
find

Let
By Extended Euclidean Algorithm, we can find $s$ and $t$ s.t. $as + bt = d$

1) Particular solution:

$x_0 = \left(\frac{c}{d}\right) s \quad $ and $\quad y_0 = \left(\frac{c}{d}\right) t$

2) General solutions:

$x = x_0 + \left(\frac{b}{d}\right)k \quad $ and $\quad y = y_0 - \left(\frac{a}{d}\right)k,\quad k \in Z$

Share