Fancier C++ solution keeps track of discovered primes to use as divisors
Setting the prime count back to 10001