lib/more_math/permutation.rb
# Computes the nth power (ie the nth repeated permutation) of this instance.
# Negative powers are taken to be powers of the inverse.
Computes the nth power  of this instance.
Negative powers are taken to be powers of the inverse.
Computes the nth power of this instance . Negative powers are taken to be powers of the inverse .
def power(n)
      if n.respond_to?(:to_int)
        n = n.to_int
      else
        raise TypeError, "#{n.inspect} cannot be converted to an integer"
      end
      if n >= 0
        (1..n).inject(identity) { |p, e| p * self }
      else 
        -power(-n)
      end
    end
def power ( n ) if n . respond_to? ( :to_int ) n = n . to_int else raise TypeError , "#{n.inspect} cannot be converted to an integer" end if n >= 0 ( 1 .. n ) . inject ( identity ) { | p , e | p * self } else - power ( - n ) end end
Computes the nth power (ie the nth repeated permutation) of this instance.
Computes the nth power ( ie the nth repeated permutation ) of this instance .
# negative powers are taken to be powers of the inverse
n
<not_specific>