Ceiling count for fixed-size batches

ID: ceiling-count-for-fixed-size-batches

Suppose is a nonnegative integer count of items and each batch holds at most items, where is a positive integer. The smallest sufficient number of batches is
Indeed, exactly when the integer is at least . If , no batches are needed. If is a multiple of , no partly filled batch is needed.
For items with capacity per batch, . Five batches can be full and the sixth holds two items, leaving unused places. This is a different question from the five complete groups counted by .
Figure 1.
Endpoint-aware integer counts and six twenty-place batches needed for 102 items
. Details.
Writing the Euclidean division , , gives the equivalent rule when , and when . This explains the ceiling function's jump: one extra item beyond a complete multiple demands a whole additional batch. For exact integer arithmetic, the identity avoids a fractional intermediate value; an implementation still needs an integer representation large enough to hold .

New to topics? Read the docs here!