Completed Euler015 in Python