Guest User

Untitled

a guest
Jan 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. export const isPrime = (num) => {
  2. if (num === 2) {
  3. return true;
  4. }
  5. if (num < 2 || num % 2 === 0) {
  6. return false;
  7. }
  8. for (let i = 3; i * i <= num; i += 2) {
  9. if (num % i === 0) {
  10. return false;
  11. }
  12. }
  13. return true;
  14. }
Add Comment
Please, Sign In to add comment