Primes puzzle solution