Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //02.Prime Number Checker
- function primeNumberChecker(numb) {
- 'use strict'
- let count = 0
- for (let i = 1; i <= numb; i++)
- if (numb % i === 0)
- count++
- console.log(count === 2 ? true : false)
- }
- primeNumberChecker1(1)
- function primeNumberChecker0(numb) {
- 'use strict'
- const isPrime0 = num => {
- for (let i = 2, s = Math.sqrt(num); i <= s; i++)
- if (num % i === 0) return false
- return num > 1
- }
- console.log(isPrime0(numb))
- }
- function primeNumberChecker1(numb) {
- 'use strict'
- const isPrime = num => {
- for (let i = 2; i < num; i++)
- if (num % i === 0) return false;
- return num > 1;
- }
- console.log(isPrime(numb))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement