How to Find the Maximum Multiple in C
The challenge
Given a Divisor and a Bound , Find the largest integer N , Such That ,
Conditions :
- N is divisible by divisor
- N is less than or equal to bound
- N is greater than 0.
Notes
- The parameters (divisor, bound) passed to the function are only positive values .
- It’s guaranteed that a divisor is Found .Input » Output Examples
|
|
Explanation:
(6) is divisible by (2) , (6) is less than or equal to bound (7) , and (6) is > 0 .
|
|
Explanation:
(50) is divisible by (10) , (50) is less than or equal to bound (50) , and (50) is > 0 .*
|
|
Explanation:
(185) is divisible by (37) , (185) is less than or equal to bound (200) , and (185) is > 0 .
The solution in C
Option 1:
Option 2:
Option 3:
Test cases to validate our solution
|
|