Power calculation in Ruby