Euler problem 2 solution as per BS