Function to check wheather num can be added to the subset
function check ( pos , subset , unique ) { for ( let num = 0 ; num < subset . length ; num ++ ) { if ( gcd ( subset [ num ] , unique [ pos ] ) != 1 ) { return false ; } } return true ; }