Euler project 114
Refactoring