Given two integers L and R, the task is to find the greatest divisor that divides all the natural numbers in the range [L, R].
Input: L = 3, R = 12
Input: L = 24, R = 24
Approach: For a range of consecutive integer elements, there are two cases:
- If L = R then the answer will L.
- If L < R then all consecutive natural numbers in this range are co-primes. So, 1 is the only number that will be able to divide all the elements of the range.
Below is the implementation of the above approach:
Time Complexity: O(1)
- Sum of greatest odd divisor of numbers in given range
- Find the k-th smallest divisor of a natural number N
- Find a distinct pair (x, y) in given range such that x divides y
- Count of numbers from the range [L, R] which contains at least one digit that divides K
- Sum of all natural numbers in range L to R
- Sum of all odd natural numbers in range L and R
- Smallest prime divisor of a number
- Sum of range in a series of first odd then even natural numbers
- Find two co-prime integers such that the first divides A and the second divides B
- Largest Divisor of a Number not divisible by a perfect square
- Greatest number less than equal to B that can be formed from the digits of A
- Highest power of a number that divides other number
- Check if the sum of digits of a number N divides it
- Largest number that divides x and is co-prime with y
- Minimum value that divides one number and divisible by other
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.