solution to project euler problem 12; ruby