<body>
</body>
<script>
const arr1=[1, 2, 3, 6, 9, 18,13,17]
const arr2=primeNumbers(Math.max(...arr1))
let arr3=[]
for (let i=0; i<=arr1.length; i++){
for (let j=0; j<arr2.length; j++){
if(arr1[i]===arr2[j]) arr3.push(arr1[i])
}
}
document.write(arr3)
function primeNumbers (n){
let arr=[]
for (let i=2; i<=n; i++){
let f=true
for (let j=0; j<arr.length; j++){
if (i%arr[j]===0){
f=false
break;
}
}
if (f){
arr.push(i)
}
}
return (arr)
}
</script>