solution to project euler problem 3; python