Refactor Euler #1 solution