Problem 26 in Ruby.