Sei sulla pagina 1di 23

Prime Numbers And

Primality Tests
- Testing Primality
- Euclids Proof
- Integer Factorization

What is Prime Number ?


Prime Number:
The number
which is divisible by 1 or itself only.
Example :
2,3,5,7,11,13.

Primality Test: A Primality Test is an algorithm to determining


whether an input number is prime or not .
Trial Division:- It is a simplest primality test .
Given an input numbern, check whether any
integermfrom 2 to n 1 evenlydividesn(the
division leaves noremainder). Ifnis divisible by
anymthenniscomposite, otherwise it isprime.

Naive method: bool isPrime(unsigned long n)


{

if (n <= 3)
{

return n > 1;

}
else if (n % 2 == 0 || n % 3 == 0)
{

return false;

}
***

***
else

}
}

{
for (unsigned short i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) {
return false;
}
}
return true;

AKS PRIMALITY TEST: This was given by three mathematician


Mahindra Agrawal , Neeraj Kayal and Nitin
Saxena at IIT Kanpur in August 6 2002 in a
paper titled PRIMES IN P .
This was a very massive invention in field of
primality testing.
Because it gives the output very fast than
other primality tests.

LOGIC OF AKS
The logic behind this test is 1.Let p be a number to check weather it is prime or not
2.Then solve this equation:(x-1)^p (x^p -1)
3.When we get final result then we check the all
coefficient
4. If the all coefficients are multiple of p than the p is
prime
5.Else number is not prime.

Complexity of AKS :-

The run time complexity


of the AKS primality test
is
O(log^21/2 n)

Euclids Theorem :Theorem:Euclid's theoremis a fundamental


statement innumber theorythat
asserts that there
areinfinitelymanyprimenumbers.

Euclids Proof: This theorem, also called the infinitude of primes


theorem, was proved Euclid in Proposition IX.20 of
theElements.
Euclid's elegant proof proceeds as follows. Given a
finite sequence of consecutive primes 2, 3, 5, ..., p,
the number N = 235. . p + 1 ,is known as the ith
Euclid number when p=pi is the ith prime, is either a
new prime or the product of primes.
If N is a prime, then it must be greater than the previous
primes, since one plus the product of primes must be
greater than each prime composing the product.

- Now, if N is a product of primes, then at least one of the


primes must be greater than p. This can be shown as follows.
If N is composite and has no prime factors greater than p,
then one of its factors (say F) must be one of the primes in
the sequence, 2, 3, 5, ..., p.
It therefore divides the product 235........ p. However, since
it is a factor of N, it also divides N.
But a number which divides two numbers a and b<a also
divides their difference a-b, so F must also divide
N-(235 p) = (235 p+1) - (235 p) = 1

- However, in order to divide 1, F must be 1, which is


contrary to the assumption that it is a prime in the
sequence 2, 3, 5, .... It therefore follows that if N is
composite, it has at least one factor greater than p.

Since N is either a prime greater than p or contains a


prime factor greater than p, a prime larger than the
largest in the finite sequence can always be found, so
there are an infinite number of primes.

INTEGER FACTORIZATION: INTRODUCTION: In number theory prime factorization is the breaking


down of a composite
number into smaller non-trivial divisors which when
multiplied together
equal the original integer.

BASIC TERMINOLOGY: Prime Numbers

A prime number (or a prime) is a natural number


which has exactly two distinct natural number divisors:
1 and itself.
Prime Factorization

In number theory prime factorization is the breaking


down of a composite number into smaller non-trivial
divisors, which when multiplied together equal the
original integer.

- SEMI PRIME
A semi-prime (also called bi-prime or 2-almost

prime, or pq number) is a natural number that is


the product of two (not necessarily distinct)
prime numbers

BASIC IDEA : The trivial way to factorise a given number is to check


whether the given number is divisible by all the primes
below that number.
But this thing is bad as brute force.
But the disadvantage of this method is that we need to
store a large amount of primes and traverse through
that for every number.
This puts an upper limit on number that can be
checked.

STEPS OF BASIC IDEA: FIND THE SQUARE ROOT OF A


GIVEN NUMBER
FIND THE LEFT CHILD
FIND THE RIGHT CHILD
AND THEN WE APPLY THESE STEPS ON
LEFT AND RIGHT CHILDREN.

PSEDU CODE FOR BASIC


APPROACH: INTEGER_FACT(n)
1. if n==1
2. return
3 else
4 Left=[sqrt(n)]
5 While left>=1 and n mod left !=0
6 left
7 if left!=1
8 right =[n/left]

- 9 INTEGER_FACT(left)
10 INTEGER_FACT(right)
11 else
12 fact->info=left
13 break
14 return(fact)

ANOTHER APPROACH: TRIALL DIVISION METHOD: Divide n with all primes up to n starting
from 2 and collect all divisors.
A very simple algorithm.
Takes time exp( log n) = L(1, ).
Notation: Denote exp(c(log n)(loglog n)1-)
as L(, c).

APPLICATION OF I.F : CRYPTOGRAPHY


- ATM
-COMPUTER SCIENCE
-AND ELECTRONIC

REFRENCES: Richard Crandall and Carl Pomerance (2001). Prime Numbers: A


Computational Perspective
Donald Knuth. The Art of Computer Programming, Volume 2:
Seminumerical Algorithms , Third :Factoring into Primes.
www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf
Kleinjung, et al (2010-02-18). "Factorization of a 768-bit RSA
modulus". International Association for Cryptologic Research.
Retrieved 2010-08-09.
Euclid's Elements, Book IX, Prop. 20 (Euclid's proof, on David
Joyce's website at Clark University)
Weisstein, Eric W., "Euclid's Theorem", MathWorld.

Thank
You !

Potrebbero piacerti anche