Finished problem 3.rb for Project Euler