Project Euler : Problem 39