Solution to problem 116 on Project Euler (https://projecteuler.net/problem=116)