complete Euler Problem 3