Refactor Proj Euler problem 008.