solution to first euler problem