Euler14 solution in scala