我在for循环中的代码中出错,for ( j = 3; j <=sqrt(num); j +=2):
多个重载函数"sqrt"的实例与参数列表匹配.
我该如何解决?
# include <cmath>
// determine if number is prime
bool isPrime (long n)
{
int j, num = 0;
{
if (num <=1)
return false;
}
for ( j = 3; j <=sqrt(num); j +=2)
{
if (num % j == 0)
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)