Greatest divisor which divides all natural number in range [ L , R ] | Java implementation of the approach ; Function to return the greatest divisor that divides all the natural numbers in the range [ l , r ] ; Driver Code
class GFG { static int find_greatest_divisor ( int l , int r ) { if ( l == r ) { return l ; } return 1 ; } public static void main ( String [ ] args ) { int l = 2 , r = 12 ; System . out . println ( find_greatest_divisor ( l , r ) ) ; } }