Hi, I have been doing an exercise to determine if an entered number is a prime number or not, apparently it works, but when passing it through a test it fails. Now is when I don't know what specific number or numbers the program didn't give the correct result. I would be grateful if you would indicate it to me (the execution time and negative number tests if you manage to pass them).
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
bool isPrime(int num) {
int count=0;
bool prime=false;
for(int i=1; i< sqrt(num); i++){
if(num%i==0){
count++;
}
}
if (count ==1 && count<=2)
{
prime=true;
}
if(prime==true){
cout<<"es primo";
}
else
{
cout<<"No es primo";
}
return prime;
}
int main(int argc, char *argv[]) {
int num;
cin>> num;
isPrime(num);
return 0;
}