Euler 65 solution in python