Max occurring divisor in an interval | Efficient Java program to find maximum occurring factor in an interval ; function to find max occurring divisor interval [ x , y ] ; if there is only one number in the in the interval , return that number ; otherwise , 2 is the max occurring divisor ; Driver program
import java . io . * ; class GFG { static int findDivisor ( int x , int y ) { if ( x == y ) return y ; return 2 ; } public static void main ( String [ ] args ) { int x = 3 , y = 16 ; System . out . println ( findDivisor ( x , y ) ) ; } }