Project Euler. Wasting time with Maths.

My attempt at #3 is running now (which probably means it is wrong).