Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const isPrime = (num) => {
- if (num === 2) {
- return true;
- }
- if (num < 2 || num % 2 === 0) {
- return false;
- }
- for (let i = 3; i * i <= num; i += 2) {
- if (num % i === 0) {
- return false;
- }
- }
- return true;
- }
Add Comment
Please, Sign In to add comment