ruby solution to project euler 1