# check prime cpp gfg

bool isPrime(int s){ if(s <= 1) return false; if(s == 2) return true; for(int i = 2; i * i <= s; i++) { if(s % i== 0) return false; } return true; }

**Here is what the above code is Doing:**

1. We are defining a function called isPrime.

2. The function takes an integer as an argument.

3. The function returns a boolean value.

4. The function checks if the number is less than or equal to 1. If it is, it returns false.

5. The function checks if the number is equal to 2. If it is, it returns true.

6. The function checks if the number is divisible by any number between 2 and the square root of the number. If it is, it returns false.

7. If the number is not divisible by any number between 2 and the square root of the number, it returns true.