IQ

Ad SpeedyAds

Sunday, February 7, 2010

Shortest Function to find if a number is prime

class prime
{
public static boolean PrimeCheck(int a)//a should be greater than 0
{
for(int i=2; i<=a/2; i++)
if(a%i==0)
return false;
return true;
}
}

1 comment: