Euler project 14 in python