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 greater than n that can be represented as a sum of distinct power of k
- Smallest number divisible by first n numbers
- Smallest K digit number divisible by X
- Smallest number with sum of digits as N and divisible by 10^N
- 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
- Number of non-decreasing sub-arrays of length greater than or equal to K
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.