Given two integers L and R, the task is to calculate the value of the expression:
Input: L = 6, R = 12
Input: L = 5, R = 6
Approach: It can be observed that .
Hence, the answer will be (1 / L) – (1 / (R + 1)).
Below is the implementation of the above approach:
Time Complexity: O(1)
- Find the minimum value of X for an expression
- Find all possible outcomes of a given expression
- Find a permutation of 2N numbers such that the result of given expression is exactly 2K
- Find the GCD that lies in given range
- Find XOR of numbers from the range [L, R]
- Find numbers with K odd divisors in a given range
- Find the occurrences of digit d in the range [0..n]
- Find numbers with n-divisors in a given range
- Find the smallest twins in given range
- Find the largest twins in given range
- Find an integer in the given range that satisfies the given conditions
- Find the number of divisors of all numbers in the range [1, n]
- Find a distinct pair (x, y) in given range such that x divides y
- Find a range of composite numbers of given length
- Find if a crest is present in the index range [L, R] of the given array
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.