Greatest divisor which divides all natural number in range [ L , R ] | C ++ implementation of the approach ; Function to return the greatest divisor that divides all the natural numbers in the range [ l , r ] ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int find_greatest_divisor ( int l , int r ) { if ( l == r ) return l ; return 1 ; } int main ( ) { int l = 2 , r = 12 ; cout << find_greatest_divisor ( l , r ) ; }