-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo13.html
More file actions
35 lines (35 loc) · 775 Bytes
/
Copy pathDemo13.html
File metadata and controls
35 lines (35 loc) · 775 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<form>
Nhập số:
<input type="number" id="input_so">
<br>
<button type="button" onclick="kiem_tra()">Kiểm tra số nguyên tố</button>
</form>
<div id="ket_qua"></div>
<script type="text/javascript">
function kiem_tra(){
let so = parseInt(document.getElementById('input_so').value);
let dem_chia_het = 0;
let ket_qua;
for(let i = 1; i <= so; i++){
if(so % 1 == 0){
dem_chia_het++;
}
}
if(dem_chia_het == 2){
ket_qua = 'Đúng';
} else {
ket_qua = 'Sai';
}
document.getElementById('ket_qua').innerHTML = ket_qua;
}
</script>
</body>
</html>