I've got a logic error in here and I am having trouble figuring it out.
Can someone please point out the obvious as I cannot see it.
TIA!Code:#include <iostream> #include <math.h> using namespace std; int main(){ int i, n, squirt; bool is_prime = true; cout << "Enter a number: "; cin >> n; squirt = sqrt(static_cast<double>(n)); for(i = 2; i <= squirt; i++){ if(i % squirt == 0){ is_prime = false; break; } } cout << n << " is "; if(!is_prime) cout << "not "; cout << "a prime number."; cout << endl; return 0; }