Code:

#include <iostream>
#define NUM_ELEMENTS(n) (sizeof n / sizeof n[0])
unsigned const long primetable[] =
{
2, 3, 5, 7, 11, 13, 17, 19, 23,
29, 31, 37, 41, 43, 47, 53, 59, 61
};
int main() {
int test_min = 5, test_max = 500;
for (int someTest = test_min; someTest < test_max; someTest++) {
bool is_prime=true;
// breaks if sqrt(someTest) > last entry in primetable
for (int i = 0; i < NUM_ELEMENTS(primetable); ++i) {
if (someTest % primetable[i] == 0) {
is_prime=false;
break;
}
}
if (is_prime) {
std::cout << someTest << " is prime" << std::endl;
} else {
std::cout << someTest << " is not prime" << std::endl;
}
}
return 0;
}