Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function primeNumberChecker(n) {
- if (n == 2 || n == 3 || n == 5 || n == 7) {
- console.log("true");
- } else if (n < 2 || n % 2 == 0) {
- console.log("false");
- } else {
- for (let i = 3; i <= Math.sqrt(n); i += 2) {
- if (n % i == 0) {
- console.log("false");
- } else {
- console.log("true");
- }
- }
- }
- }
- primeNumberChecker(7);
- primeNumberChecker(8);
- primeNumberChecker(81);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement