Max Multiple
Given a divisor
and a bound
, find the largest integer N
such that:
N
is divisible bydivisor
.N
is less than or equal tobound
.N
is greater than0
.
It is guaranteed that such a number exists.
Example
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
.
Solution
py
def max_multiple(divisor, bound):
return (bound // divisor) * divisor
print(max_multiple(3, 10))