solved problem 99 in ruby (with logarithms)