Refactored euler 1