cpp_is_king
Member
Oh this solved it!! I was building it in debug and now in release it works! Thanks so much. And about the bool, I don't understand how I can return true or false when there is also a chance of returning the recursive method which isn't a boolean.
If you make prime return a bool, then the recursive call (which is a call to prime) will return a bool.
Code:
bool prime(int x, int i)
{
if (i == 1)
return true;
else
{
if (x % i == 0)
return false;
else
return prime(x, i - 1);
}
}
In the final return statement, where it returns the recursive call, it is returning a bool (see line 1, where the function is declared as "bool prime..."