-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.html
More file actions
37 lines (33 loc) · 987 Bytes
/
prime.html
File metadata and controls
37 lines (33 loc) · 987 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>소수 판별 프로그램</h2>
<script>
debugger;
var s1 = prompt("숫자를 입력해 주세요.");
var n1 = Number(s1);
for(var i = 2; i < n1; i++){
// if(n1 % i === 0){
// console.log(n1 + "는 소수가 아닙니다.");
// }else{
// console.log(n1 + "는 소수입니다.");
// }
var isPrimeNumber = true;
if (n1 % i === 0){
isPrimeNumber = false;
break;
}
}
if (isPrimeNumber === true){
console.log(n1 + "는 소수입니다");
} else{
console.log(n1 + "는 소수가 아닙니다.");
}
</script>
</body>
</html>