Solves Project Euler Problem 036.