39, rewrite with sieve of Eratosthenes