Prime number function

int isPrime(int n)//check if the number is prime and return 1 if prime
{
     int i;
     if (n==2)
         return 1;
    if(n%2==0)
        return 0;
   for(i=3;i<=n/2;i+=2)
     {
       if(n%i==0)
          return 0;
     }
     return 1;
}

Comments

Popular Posts