Showing posts with label optimized prime number program. Show all posts
Showing posts with label optimized prime number program. Show all posts

Friday, April 23, 2010

Optimized Program for Prime number in c#

public bool IsPrime(int x)
{
if (x == 2 x==3)
return true;
else
if (x % 2 == 0 x < 2 x % 3 == 0)
return false;
Double t=Math.Sqrt((Double)x);
for (int i = 3; i {
if (x % i == 0)
return false;
}
return true;
}