https://school.programmers.co.kr/learn/courses/30/lessons/42839
//소수판별
function isPrime(num){
if (num <= 1) return false
for(let i = 2; i <= Math.sqrt(num); i++){
if(num%i===0) return false
}
return true
}
function solution(numbers) {
let visited = new Array(numbers.length).fill(0);
let answer = [];
//순열 구하기
const dfs = (result)=>{
if(result != "" && isPrime(parseInt(result)))
answer.push(parseInt(result))
for (let i=0; i<numbers.length; i++){
if (!visited[i]){
visited[i]=1;
dfs(result+numbers[i]);
visited[i]=0;
}
}
}
dfs("");
// 중복제거후 개수 리턴
return new Set(answer).size
}