Last active
July 3, 2019 01:58
-
-
Save Kkan9ma/711e41911a2ca105c624a66d9b781f06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>소수 판별기</title> | |
</head> | |
<body> | |
<h1> 소수 판별 프로그램 </h1> | |
<script> | |
var num = Number(prompt("2 이상의 정수를 입력하세요")); | |
var isPrime = true; | |
for (var i = 2; i < num; i++) { | |
if (num % i === 0) { | |
isPrime = false; | |
break; | |
} | |
} | |
if (isPrime) { | |
document.write (num + "은 소수입니다.") | |
} else { | |
document.write (num + "은 소수가 아닙니다." + " (" + i + "을(를) 원소로 갖는다.)"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment