I have been trying to create my own prime checker function, although strangely when I call isPrime(7) it returns 1, which is good, but when I call isPrime(9) it gives me the following error:
'Mathematics.exe': Loaded 'C:\Documents and Settings\mbryant\My Documents\Visual Studio 2010\Projects\Mathematics\Debug\Mathematics.exe', Symbols loaded. 'Mathematics.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file 'Mathematics.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file 'Mathematics.exe': Loaded 'C:\WINDOWS\system32\msvcp100d.dll', Symbols loaded. 'Mathematics.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded. The thread 'Win32 Thread' (0x6ec) has exited with code -1073741510 (0xc000013a).
The program '[6072] Mathematics.exe: Native' has exited with code -1073741510 (0xc000013a).
Here is the code:
#include <iostream>
using namespace std;
bool isPrime(int x){
int b = 0;
int i = 2;
if(x == 2){
return 1;
}
if (x > 2){
while(i < x){
if ( (x % i) != 0){
b = b + 1;
i = i + 1;
}
}
if (b > 0){
return 1;
} if (b == 0){
return 0;
}
}
}
int main(){
cout << isPrime(9) << endl;
system("pause");
return 0;
}
Helping with resolving this issue would be greatly appreciated.