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))