Skip to content

Instantly share code, notes, and snippets.

@Ankitashah212
Created August 29, 2017 17:52
Show Gist options
  • Save Ankitashah212/1f7d6b53f8ba22f78335e52413dfa597 to your computer and use it in GitHub Desktop.
Save Ankitashah212/1f7d6b53f8ba22f78335e52413dfa597 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<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>Document</title>
</head>
<body>
<script>
function isPrime(number) {
checkPrime = true;
if (number % 2 == 0) {
checkPrime = false;
}
else {
var range = Math.ceil(number / 3);
for (var i = 3; i < range; i += 2) {
if ((number % i) == 0) {
checkPrime = false;
}
}
}
return checkPrime;
}
console.log(isPrime(11));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment