Ruby solution for euler05