Simple solution using a closure to hold primes... quite slow though