Ruby 3.2.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Integerクラス > ceildiv

instance method Integer#ceildiv

ceildiv(other) -> Integer[permalink][rdoc]

self を other で割り、その(剰余を考えない)商を整数に切り上げたものを返します。すなわち、self を other で割った商を q とすると、q 以上で最小の整数を返します。

[PARAM] other:
self を割る数を指定します。

3.ceildiv(3)    # => 1
4.ceildiv(3)    # => 2
5.ceildiv(3)    # => 2
3.ceildiv(1.2)  # => 3
-5.ceildiv(3)   # => -1
-5.ceildiv(-3)  # => 2