Question #5908

write a function to take an int argument and return 0 if the given number is prime otherwise return -1.

Expert's answer

int isprime(int valuex)

{

int x,j;

x=1;

& for (j=2 ; j<valuex; j++)

{ if ((valuex%j)==0) x=0; }

& if(x!=0) return 0;

& else return (-1);

}

{

int x,j;

x=1;

& for (j=2 ; j<valuex; j++)

{ if ((valuex%j)==0) x=0; }

& if(x!=0) return 0;

& else return (-1);

}

## Comments

## Leave a comment