Function to find the minimum element
static int getMin ( int [ ] arr , int n , int k ) { int res = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) { res = Math . Min ( res , arr [ i ] ) ; } } return res ; }