Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js is prime

function isPrime(num) {
  for(var i = 2; i < num; i++){
    if(num % i === 0){ 
      return false;
    }
  }
  return num > 1;
}
Comment

js is prime

function isPrime(num) {
  if(num === 2) return true;
  if(num % 2 === 0) return false;
  for(var i = 3; i <= Math.sqrt(num); i += 2){
    if(num % i === 0) return false;
  }
  return num > 1;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript find all href with same value 
Javascript :: adding a prototype on vue using nuxt 
Javascript :: angular input date binding on variable update 
Javascript :: remove value from array javascript 
Javascript :: javascript trigger click on element 
Javascript :: javascript canvas without html 
Javascript :: jquery select2 hide search box 
Javascript :: mongodb password in connection string with @ 
Javascript :: remove a particular element from array 
Javascript :: javascript for...in with Strings 
Javascript :: js pgrah 
Javascript :: js how to know if element touch border 
Javascript :: adonisjs findorcreate 
Javascript :: Iterate with JavaScript While Loops 
Javascript :: switch case javascript 
Javascript :: download file axios nodejs 
Javascript :: how to lock device orientation using css and javascript 
Javascript :: how to get the sum of a column in sequelize 
Javascript :: - Root composer.json requires tymon/jwt-auth ^0.5.12 - satisfiable by tymon/jwt-auth[0.5.12]. 
Javascript :: sentido etimología 
Javascript :: html2canvas cdn 
Javascript :: js simulate click 
Javascript :: axios not defined 
Javascript :: wait n seconds in js 
Javascript :: keyup addeventlistener 
Javascript :: htmlparser2 extract text from html 
Javascript :: how to do regex email validation with domain 
Javascript :: axios header accept language 
Javascript :: process memory usage javascript 
Javascript :: javascript reverse string without reverse method 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =