Project Euler 7 solved