I have made a small c++ program to check for prime numbers. It seems to work pretty well, but after a while it stops when it gets to 16777213. Can anyone tell me why? Here is my program:
#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int n) {
if (n <= 1) return false;
for (int i = 2; i <= sqrt(n); i++) {
float div = n/float(i);
if (!(div-floorf(div))) return false;
}
return true;
};
int main() {
for(int a = 1; a < 18446744073709551614; a++ )
if (isPrime(a))
cout << a << endl;
return 0;
}