Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Primality Tests
- Testing Primality
- Euclids Proof
- Integer Factorization
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;
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 :-
- SEMI PRIME
A semi-prime (also called bi-prime or 2-almost
- 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).
Thank
You !