A very useful generator for primes

I think the code I wrote yesterday is ugly now///