Driver code
public static void main ( String [ ] args ) { int arr [ ] = { 2 , 6 , 9 } ; int n = arr . length ; int prefix [ ] = new int [ n ] ; int suffix [ ] = new int [ n ] ; FillPrefixSuffix ( prefix , arr , suffix , n ) ; int l = 0 , r = 0 ; System . out . println ( GCDoutsideRange ( l , r , prefix , suffix , n ) ) ; l = 1 ; r = 1 ; System . out . println ( GCDoutsideRange ( l , r , prefix , suffix , n ) ) ; l = 1 ; r = 2 ; System . out . println ( GCDoutsideRange ( l , r , prefix , suffix , n ) ) ; } }