Exercise 3 - Project Euler - working solution