Max occurring divisor in an interval | Efficient C ++ 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 code
#include <iostream> NEW_LINE using namespace std ; int findDivisor ( int x , int y ) { if ( x == y ) return y ; return 2 ; } int main ( ) { int x = 3 , y = 16 ; cout << findDivisor ( x , y ) ; return 0 ; }