A general solution to Problem Euler 1