0% found this document useful (0 votes)
86 views14 pages

Greatest Common Divisor - GCD: GCD - Prime Factorization Method

The document discusses several topics related to number theory including: 1. Greatest common divisor (GCD) methods like prime factorization and the Euclidean algorithm. 2. The fundamental theorem of arithmetic which states every integer can be written as a unique product of prime numbers. 3. Congruences, including the definition of congruence, linear congruences, and the Chinese remainder theorem.

Uploaded by

Anudeep P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views14 pages

Greatest Common Divisor - GCD: GCD - Prime Factorization Method

The document discusses several topics related to number theory including: 1. Greatest common divisor (GCD) methods like prime factorization and the Euclidean algorithm. 2. The fundamental theorem of arithmetic which states every integer can be written as a unique product of prime numbers. 3. Congruences, including the definition of congruence, linear congruences, and the Chinese remainder theorem.

Uploaded by

Anudeep P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Greatest Common Divisor - GCD

GCD - Prime Factorization Method

GCD - Euclidean Algorithm Method

The Fundamental Theorem of Arithmetic

Factorization of Integers And The Fermat Numbers


GCD - Prime Factorization Method

Every composite number, i.e. a number with more than one factor can be written
as a product of prime numbers.
In the prime factorisation method, each given number is written as the product
of prime numbers and then find the product of the smallest power of each
common prime factor.
This method is applicable only for positive numbers, i,e. Natural numbers.
Example: Find the Greatest common factor of 24, 30 and 36.
Solution: Prime factors of 24 is 23 × 3
Prime factors of 30 = 2 × 3 × 5
Prime factors of 36 = 2² x 3²
From the factorisation, we can see, only 2 x 3 are common prime factors.
Therefore, GCD (24, 30, 36) = 2 x 3 = 6
GCD - Prime Factorization Method
SOURCE CODE
def computeGCD(x, y):

if x > y:
small = y
else:
small = x
for i in range(1, small + 1):
if((x % i == 0) and (y % i == 0)):
gcd = i OUTPUT
return gcd
a = 60
b = 48
# prints 12
print ("The gcd of 60 and 48 is : ", end="")
print (computeGCD(60,48))
GCD - Euclidean Algorithm Method

In this method, the largest number among the given set of numbers should be
divided by the second largest number, and again the second-largest number
should be divided by the remainder of the previous operation, this process will
continue till the remainder is zero. The divisor, when the remainder is zero, is
called the greatest common divisor of the given numbers.
Example : Find the greatest common divisor of 128 and 96.
Solution : By the method of Euclidean algorithm,
Step 1 : 128 = 96 x 1 + 32
Step 2 : 96 = 32 x 3 + 0

Hence, 32 is the GCD of 128 and 96.


GCD - Euclidean Algorithm Method

SOURCE CODE
# euclid algorithm for calculation of greatest common divisor
def gcd(a, b):
if a == 0 : OUTPUT
return b
return gcd(b%a, a)
a = 11
b = 15
print("gcd of ", a , "&" , b, " is = ", gcd(a, b))
The Fundamental Theorem of
Arithmetic

Theorem: Every positive integer greater than 1 can be


written uniquely as a prime or as the product of two or
more primes where the prime factors are written in
order of nondecreasing size.

Examples:
. 100 = 2 . 2 . 5 . 5 = 22 . 52
. 641 = 641
. 999 = 3 . 3 . 3 . 37 = 33 . 37
. 1024 = 2 . 2 . 2 . 2 . 2 . 2 . 2 . 2 . 2 . 2 = 210
Fermat’s method of factorization

Suppose we know that a number is composite


n=a*b
where a, and known as quantities then we apply Fermatod of factorization.
That is n=a*b
n=(a+b/2)`2-(a-b/2)`2
where , t=(a+b/2)`2,s=(a-b/2)`2
n=t`2-s`1
n=(t+s)(t-s)
where, t-s !=1
then we have to find non-trivial factors
where t is the greatest integer function
If t`2-s`2 is the perfect square then our problem ends
If t`2=n+s`2 is not a perfect square root then continue the process until it
becomes perfect square numbers
Congruences

Introduction to congruences - Properties of congruence

Linear congruences

The Chinese Remainder Theorem

System of Linear Congruences


Introduction to congruences -
Properties of congruence

Let a,b be two integers and m is the +ve integer then if a-b divides m then we say,
the relation is a congruent.
It is denoted by a ≡ b(modm)
Basic properties of Congruence
The Congruent relation is said to be equivalent relation if a,b,c belongs to (integer) Then the
relation is Conguient. if it satisfies
The following properties...
→ Reflexive property
a ≡ a (mod m)
→ Symmetric property
a ≡ b (mod m)
b ≡ a (mod m)
→ Transitive property
a ≡ b (mod in)
b ≡ c (mod m)
a ≡ c (mod m)
Linear congruences

Rules for finding x in linear congruence :

The general format is ax ≡ b (mod m)


step 1 : find GCD(a,x)=d
step 2 : b/d -> if possible solution exist
step 3 : find d mod m-> number of solutions possible
step 4 : divide both sides by d
step 5 : multiply both sides by the inverse of "a"
step 6 : after getting a.a inverse x= b a inverse mod m
find the general solution where t = 1,2,3,.......t-1
x(t)=xO+t(m/d)
The Chinese Remainder Theorem

Statement:
Let m1,m2. ...,mr, be pairwise relatively prime
positive integers
and a1, a2 ..., an arbitrary integers. Then the
system
x= a1 (mod m,)
x= a2 (mod m2)
.
.
x = an (mod mr)
has a unique solution modulo m = m1, m2...mr.
Algorithm for
Chinese Remainder Theorem

Step 1:- Find M = m x m2 x ... x mk. This is the


common modulus.
Step 2:- Find M1 = M/m1,, M2 = M/m2, ...,Mk =
M/mk-
Step 3:- Find the multiplicative inverse of M1,
M2, ...,Mk using the corresponding moduli (m1,
m2, ..., mk). Call the inverses as:-
M1-', M2-', ..., Mk-'
step 4:-The solution to the simultaneous
equations is:-
x=((a1xM1xM1-') +(a2xM2xM2-')+ ...+ (akxMkXMk-') mod M
System of Linear Congruences

You might also like