#include <iostream>
#include <vector>
#include <inttypes.h>
#include <cmath>
//compile on osx: clang -lstdc++ ./erato.cpp -o erato
//compile on cygwin clang++ -lgmp -lstdc++ ./erato.cpp -o erato
//sieve and main omitted
uint64_t maximum_prime_product(uint64_t limit)
{
std::vector<uint64_t> primes = primes_to(limit/2);
uint64_t i = 0;
uint64_t j = primes.size() - 1;
uint64_t max_product = 0;
while (i <= j)
{
while ((primes[i] * primes[j]) > limit)
{
j--;
}
if ((primes[i] * primes[j]) > max_product)
max_product = primes[i] * primes[j];
i++;
}
return max_product;
}