“”"
#include
#include
using namespace std;
void isPrime(int TheNum,bool isprime){
for (int theDivison = 2; theDivison <= TheNum/2; theDivison++){
if (TheNum% theDivison == 0){
isprime = false;
break;
}
}
}
int main(){
int n = 3;
int TheSum = 2;
bool CouldDivide = true;
while (n <= 2000000){
isPrime(n,CouldDivide);
if (CouldDivide == true){
TheSum += n;
}
n = n+2;
}
cout <<TheSum;
return 0;
}
“”"
My code above got the output which is a negative integer. Can anyone explain it for me?