-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecimal.js
More file actions
38 lines (32 loc) · 799 Bytes
/
decimal.js
File metadata and controls
38 lines (32 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//굳이 배열로 입력받는것보다 문자열로 입력받는게 더 편함. 2차원배열이 되면 분리하기 힘들어짐.
const readline = require('readline');
const rl = readline.createInterface({
input : process.stdin,
output : process.stdout
})
let input = '';
let count = 0;
var n = 0;
rl.on('line',function(line){
if(n == 0)
n = line
else
input +=line.trim();
})
rl.on('close',function(){
input = input.split(" ").map((item)=>parseInt(item));
for(let i = 0 ;i<n;i++){
if(isPrime(input[i]))
++count;
}
console.log(count);
})
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;
}