solution to project euler problem 4; ruby