Beruflich Dokumente
Kultur Dokumente
2. Collect
3. Pick
2. Common
3. Greatest
So GCD(25, 35) = 5.
Exercise: Compute GCD(a, 0) where a > 0.
Answer: a.
Two integers a and b are called relatively prime or co-prime if
GCD(a, b) = 1.
Example: Since GCD(4, 9) = 1, 4 and 9 are relatively prime
(or co-prime).
(3) Division algorithm
Generally it is not possible to represent the result of integer
division by one integer. For example, 5/2 = 2.5 but 2.5 is a
decimal, not an integer.
Division algorithm represent the result of integer division by
two integers: quotient and remainder. Let a and b be two
integers, where b > 0. If two integers q and r satisfy
a = q*b + r where 0 r < b,then q is called the quotient of a
divides b, and r is called the remainder of a divides b.
Example: Given a = 7 and b = 3. Since
or equivalently,
2 3)7
)1
6
2 is the quotient of 7 divides 3, and 1 is the remainder of 7
divides 3.In java programming language,1. If a and b are two
integer variables which hold positive integers, then the
expression
a/b; returns the quotient of a divides b, and the expression
a%b;
returns the remainder of a divides b.
2. Exercise: What is the java code to return the quotient and
remainder of a divides b if a holds negative integer and b
holds positive integer?Answer: a%b 1, a%b + b.
(4) Mod operator
Let n be a positive integer, (mod n) is a unary post operator
mapping the operand to the remainder of the operand divides
n.
For example, since 5 = 1*3 + 2 where 0 2 < 3, the
remainder of 5 divides 3 is 2. Therefore 5 (mod 3) = 2.
Two integers a and b are called congruent mod n, denoted by
a b (mod n) ( is called triple bar),
2. If
Division
Let Zp = {0, 1, ..., p1} be the residue set where p is a positive
1
EEA(11, 3): q = 3, r = 2, call EEA(3, 2),
2
EEA(3, 2): q = 1, r = 1, call EEA(2, 1),
3
EEA(2, 1): q = 2, r = 0, call EEA(1, 0),
4
return (1, 0)
/
NA
NA
NA
NA
NA
NA
NA