Project Euler Problem 77