Fixes the Project Euler problem 18