Find the largest possible k | C # program to find the largest possible k - multiple set ; 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
using System ; using System . Collections . Generic ; public class GFG { static void K_multiple ( int [ ] a , int n , int k ) { Array . Sort ( a ) ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] % k == 0 && ! s . Contains ( a [ i ] / k ) ) a [ i ] % k != 0 ) s . Add ( a [ i ] ) ; } foreach ( int i in s ) Console . Write ( i + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 4 , 5 , 6 , 10 } ; int k = 2 ; int n = a . Length ; K_multiple ( a , n , k ) ; } }