- Greedy, Mathematical, Prime Number, Searching

Number which is co-prime with all integers from a given range

Number which is co-prime with all integers from a given rangeGiven two positive integers L and R, the task is to find an integer X greater than 1 such that X is co-prime with all the integers from the range [L, R].Examples:Input: L = 16, R = 17 Output: 19Explanation: Only number which is co-prime with all the integers from the range [16, 17] is 9.Input: L = 973360, R = 973432 Output: 973439Approach: The simplest approach to solve the given problem is to find a prime number greater than R, because this integer does not divide any integer in the range of [L, R]. Therefore, the idea is to iterate from the value (R + 1) and if there exists any integer which is prime, then print that integer and break out of the loop.Below is the implementation of the above approach:C++  #include using namespace std;  bool isPrime(int N){        if (N == 1)        return false;      for (int i = 2; i * i