solution for the second euler problem