Solved 8 in ruby

Solved problem 8 in ruby