All pastes #733217 Raw Edit

Stuff

public text v1 · immutable
·published 2007-10-11 16:59 UTC
rendered paste body
//1 - true
//0 - false
//input is guaranteed to be positive
//assume the containing module include math
int isPrime(int inVal)
{
  
  if(inVal < 4)
  {
    return true;
  }//if "easy" prime number

  int i;
  int stopVal = (int)(sqrt( (double)inVal ));
  for(i=2; i <= stopVal; i=i+1)
  {
    if !(inVal % i)
    {
      return 0;
    }//end "if inVal % i is zero"
  }//end for loop over inval
   
  return 1;
}//isPrime