hwo to make ana array of prime numbers in javascript

Solutions on MaxInterview for hwo to make ana array of prime numbers in javascript by the best coders in the world

showing results for - "hwo to make ana array of prime numbers in javascript"
Livia
14 Apr 2019
1function sort_prime(num) {
2
3  var prime_num1 = [],
4      prime_num2 = [];
5  for (var i = 0; i <= num; i++) {
6    prime_num2.push(true);
7  }
8  for (var i = 2; i <= num; i++) {
9    if (prime_num2[i]) {
10      prime_num1.push(i);
11      for (var j = 1; i * j <= num; j++) {
12        prime_num2[i * j] = false;
13      }
14    }
15  }
16
17  return prime_num1;
18}
19
20console.log(sort_prime(5))
queries leading to this page
generate n primes javascripthow to find prime number in an array using for loop in javascriptprime number generator javascriptjavascript get primesgenerate prime number jshow to print prime number in javascriptjavascript prime number generatorfind prime numbers in array javascriptprime number generator javascript output stringcode to print prime numbers jsprime numbers generator jsjavascript generate 50 first prime numbershow do i print prime numbers in javascript 3farray with prime numbersreturn all prime numbers in array javascriptjavascript generate prime numbersjs find prime numbers up to njavascript generate prime numbers in rangearray of all primes javascriptprime numbers in order javascript codeprint prime numbers in jshow to make an array of prime numbers in javascriptprint a new array of prime numbers from the given array elements in javascripthow to display prime numbers in htmlprint prime numbers accumulator javascriptget all prime numbers before number javascripthow to generate an array of prime numbers in javascriptprime numbers in order javascriptprint prime numbers in javascriptprime numbers array javascriptconvert single number into prime numbers array in javascriptprime numbers in an array using jscreate a prime number generator in javascriptjs print primesoutput prime numbers and the numbers in javascriptgenerate prime numbers javascriptjavascript get 50 prime numbersfirst 10 prime number in javascriptjavascript print prime numbersprint all the primes javascripthwo to make ana array of prime numbers in javascripthwo to make ana array of prime numbers in javascript