Problem 6 of Project Euler Plus in Ruby