Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

prime number js

function findPrime(to) {
	let factor;
 	for (let n = 0; n < to; n++) {
    	factor = 0
    	for (let p = 0; p < to; p++)
        	if (n % p == 0) factor++;
      	if (factor == 2) console.log(n);
  	}
}

console.log(30) //2 3 5 7 11 13 17 19 23 29
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #prime #number #js
ADD COMMENT
Topic
Name
4+9 =