Solved problem 27 (along with implementing a nice dynamically doubling prime sieve).