Given three positive integers A, B and C. The task is to find the maximum integer X > 0 such that:
- X % C = 0 and
- X must belong to the range [A, B]
Print -1 if no such number i.e. X exists.
Input: A = 2, B = 4, C = 2 Output: 4 B is itself divisible by C. Input: A = 5, B = 10, C = 4 Output: 8 B is not divisible by C. So maximum multiple of 4(C) smaller than 10(B) is 8
- If B is a multiple of C then B is the required number.
- Else get the maximum multiple of C just lesser than B which is the required answer.
Below is the implementation of the above approach:
- Minimum positive integer divisible by C and is not in range [A, B]
- Biggest integer which has maximum digit sum in range from 1 to n
- Minimum positive integer value possible of X for given A and B in X = P*A + Q*B
- Print first k digits of 1/n where n is a positive integer
- Minimum positive integer to divide a number such that the result is an odd
- Count of m digit integers that are divisible by an integer n
- Find a positive number M such that gcd(N^M, N&M) is maximum
- Find an integer in the given range that satisfies the given conditions
- Sum of all numbers divisible by 6 in a given range
- Count positive integers with 0 as a digit and maximum 'd' digits
- Maximum number of distinct positive integers that can be used to represent N
- Minimum integer such that it leaves a remainder 1 on dividing with any element from the range [2, N]
- Count numbers in range 1 to N which are divisible by X but not by Y
- Count the numbers divisible by 'M' in a given range
- Numbers that are not divisible by any number in the range [2, 10]
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.