Solution of Project Euler Exercise 34