Consider the following naive monte Carlo algorithn for primality testing of a number n.
isPrimeMonteCarlo(n,t){
/*
* Take an integer n as input and check wheather it is prime or not
* using the naive monte carlo method.
* If the number is prime return True else return False.
* */
if(n<=1)
return False
m = sqrt(n);
for i = 1 to t:
j = random()%m+2
if n%j==0:
return False
return True
}
Find the value of t such that the algorithm produces the correct output with high probability?
What i could come up with so far:
Assume n is non prime, the algorithm will fail when it outputs that n is prime.This happens when no number j gives n%j==0. j is chosen from [2,sqrt(n)+2]. We want j such that j does not divide n in any of the t iterations.
Any such j must be a divisor of n. The problem reduces to finding the number of divisors of n such that they are <= sqrt(n)+2. I am not able to find a bound on this number. Any help would be appreciated.