solution to pEuler problem3