Given a number N and a number K, the task is to find the smallest number greater than or equal to N which is divisible by K.
Input: N = 45, K = 6 Output: 48 48 is the smallest number greater than or equal to 45 which is divisible by 6. Input: N = 11, K = 3 Output: 12
Approach: The idea is to divide the N+K by K. If the remainder is 0 then print N else print N + K – remainder.
Below is the implementation of the above approach :
Smallest number greater than or equal to 45 that is divisible by 6 is 48
- Smallest Special Prime which is greater than or equal to a given number
- Smallest power of 4 greater than or equal to N
- Smallest number greater or equals to N such that it has no odd positioned bit set
- Smallest number divisible by first n numbers
- Smallest number with sum of digits as N and divisible by 10^N
- Smallest K digit number divisible by X
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- C++ Program for Smallest K digit number divisible by X
- Find Nth smallest number that is divisible by 100 exactly K times
- Smallest number divisible by n and has at-least k trailing zeros
- Length of the smallest number which is divisible by K and formed by using 1's only
- Smallest n digit number divisible by given three numbers
- Java Program for Smallest K digit number divisible by X
- Largest number smaller than or equal to N divisible by K
- Count number of binary strings such that there is no substring of length greater than or equal to 3 with all 1's
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.