Check if an array can be split into subarrays with GCD exceeding K | Function to check if it is possible to split an array into subarrays having GCD at least K ; Iterate over the array arr [ ] ; If the current element is less than or equal to k ; If no array element is found to be less than or equal to k ; Given array arr [ ] ; Length of the array ; Given K ; Function call
function canSplitArray ( arr , n , k ) { for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] <= k ) { return " " ; } } return " " ; } let arr = [ 2 , 4 , 6 , 1 , 8 , 16 ] ; let N = arr . length ; let K = 3 ; document . write ( canSplitArray ( arr , N , K ) ) ;