Contains spoilers for projecteuler.net.