Check if input is a prime number
int prime_check(int num) { //2 is the only even prime number if(num == 2) return 1; //if num is even and not 2, then it is not prime else if(num % 2 == 0) return 0; //check all odd numbers up to sqrt of num to see if they are factors for(int i = 3; i <= sqrt(num); i+=2) { if(num % i == 0) return 0; } return 1; }