Solved Euler problem 3