Find the largest possible k | Function to find the largest possible k - multiple set ; Sort the given array ; To store k - multiple set ; Traverse through the whole array ; Check if x / k is already present or not ; Print the k - multiple set ; Driver code ; Function call
function K_multiple ( a , n , k ) { a . sort ( ( a , b ) => a - b ) ; let s = new Set ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] % k == 0 && ! s . has ( a [ i ] / k ) ) a [ i ] % k != 0 ) s . add ( a [ i ] ) ; } for ( let i of s ) { document . write ( i + " " ) ; } } let a = [ 2 , 3 , 4 , 5 , 6 , 10 ] ; let k = 2 ; let n = a . length ; K_multiple ( a , n , k ) ;