Skip to content

Max Multiple

Given a divisor and a bound, find the largest integer N such that:

  • N is divisible by divisor.
  • N is less than or equal to bound.
  • N is greater than 0.

It is guaranteed that such a number exists.


For divisor = 3 and bound = 10, the output should be

max_multiple(divisor, bound) = 9

The largest integer divisible by 3 and not larger than 10 is 9.


def max_multiple(divisor, bound):
    return (bound // divisor) * divisor

print(max_multiple(3, 10))

my thoughts are neither my employer's nor my wife's