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

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

instance method Integer#%

self % other -> NumericRuby 2.4.0 から[permalink][rdoc][edit]
modulo(other) -> Numeric

selfother で割った余り(剰余)を返します。

Integer オブジェクトを左項とする算術演算子 % はこのメソッドの呼び出しになります。

p  5 %  3 # =>  2
p  5 % -3 # => -1
p -5 %  3 # =>  1
p -5 % -3 # => -2
[PARAM] other:
self に対する除数