このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.0 リファレンスマニュアル

instance method Integer#pow

pow(other) -> NumericRuby 2.5.0 から[permalink][rdoc][edit]
pow(other, modulo) -> Integer

selfother 乗を返します。 modulo を指定しない場合は Integer#** と同じです。

[PARAM] other:
self に対する冪指数(べきしすう)
[PARAM] modulo:
指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
[EXCEPTION] TypeError:
2引数 powothermoduloInteger 以外を指定した場合に発生します。
[EXCEPTION] RangeError:
2引数 powother に負の数を指定した場合に発生します。
p 2.pow(3) # => 8
p 3.pow(3,  8)  # =>  3
p 3.pow(3, -8)  # => -5
p 3.pow(2, -2)  # => -1
p -3.pow(3,  8) # =>  5
p -3.pow(3, -8) # => -3
p 5.pow(2, -8)  # => -7

[SEE_ALSO] Integer#**