Sieve of Eratosthenes implemented in c++ and javascript