Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function primeNumberChecker(n) {
- let isPrime = false;
- if (n === 1) {
- isPrime = false;
- }
- if (n === 2) {
- isPrime = true;
- }
- for(let x = 2; x < n; x++) {
- if(n % x === 0) {
- isPrime = false;
- break;
- } else {
- isPrime = true;
- }
- }
- console.log(isPrime? 'true' : 'false');
- }
Advertisement
Add Comment
Please, Sign In to add comment