trying to solve Project Euler in ruby