Professional Documents
Culture Documents
Integers: Greatest Common Divisor and Euclidean Algorithm
Integers: Greatest Common Divisor and Euclidean Algorithm
An integer is a number which can be positive or negative or zero. The types of numbers
could be any number such as natural numbers, whole numbers, real number and rational
numbers.
Integers are numbers which cannot be decimals or fractions. They are either whole numbers or
negative numbers. Some examples are: 2, 7, 0, -9, -12, etc.
Rules of Integers
The rules of integers are defined by the operations performed on them. Such as:
Adding of integers
Subtracting of integers
Multiplication of integers
Division of integers
Adding integers
If we add two positive integers, then the sign of the resultant integers remains the same.
Example: 5 + 7 = 12.
If we add two negative integers, then the sign of the resultant integer will be negative.
Example: (-5)+(-7) = -5-7 = -12
If we add one positive integer and one negative integer, then the sign of the result will
depend on the integer having greater value. Example: 5 + (-7) = -2
Subtracting Integers
If we subtract two positive integers, then the sign of the resultant integer will depend on
the greater value. Example: 9 – 2 = 7
If we subtract two negative integers, then the sign of the second integer is changed to
positive and the sign of output will be the sign of greater value. Example: (-5)-(-7) = -5+7
=2
Is 0 an integer?
Yes, zero is an integer, apart from negative and positive real numbers. If we have to represent
the integers as a whole with 0, then it can be done as:
……….,-10, -9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10…
If a and b are two numbers then the greatest common divisor of both numbers is denoted by gcd
(a, b). To find the gcd of numbers, we need to list all the factors of the numbers and find the
largest common factor.
Suppose, 4, 8, and 16 are three numbers. Then the factors of 4, 8 and 16 are:
4 → 1, 2, 4
8 → 1, 2, 4, 8
16 → 1, 2, 4, 8, 16
Therefore, we can conclude that 4 is the highest common factor among all three numbers.
GCD
GCD is the greatest common factor of two or more numbers. A factor that is the highest among
the numbers.
Example 1 12 33
Divisors 1, 2, 3, 4, 6, 12 1, 3, 11, 33
Common Divisors 1, 3
Greatest Common Divisor
3
(GCD)
Example 3 13 33
Divisors 1, 13 1, 33
Common Divisors 1
Greatest Common Divisor
1
(GCD)
GCD (13, 33) = 1
2
0 3
Euclid’s Algorithm for Finding GCD 12 33
24
Method 1
Ex. 1 Find the GCD (12, 33). 9
Q A B R
1 3
2 33 12 9 9 12 3 9
9 9 9
1 12 3
3 0
3 9 3 0
X 3 0 X
1 5
Ex. 2 Find the GCD (750, 900). 750 900 150 750
750 750
Q A B R 150 0
1 900 750 150
X 150 0 X
Method 2
Prerequisite: a > b
Euclid_GCD (a, b):
If b = 0 then
return a;
else
return Euclid_GCD (b, a mod b);