#Node.js (JavaScript/ES6), 83.549s (11 Nov 2016)
Node.js (JavaScript/ES6), 83.549s (11 Nov 2016)
var n=process.argv[2]*1,r=new Uint8Array(n),p=0,i=1,j while(++i<=n){ if(r[i]===0){ for(j=i*i;j<=n;j+=i){r[j]=1} p+=1 } } console.log(p) Finally got around to remaking this, and it's both smaller/simpler and MUCH faster than before. Rather than a slower brute force method, it utilizes the Sieve of Eratosthenes alongside more efficient data structures, so that it is now able to actually finish in a respectable time (as far as I can find on the internet, it's the fastest JS prime count function out there).
Some demo times (i7-3770k):
10^4 (10,000) => 0.001 seconds 10^5 (100,000) => 0.003 seconds 10^6 (1,000,000) => 0.009 seconds 10^7 (10,000,000) => 0.074 seconds 10^8 (100,000,000) => 1.193 seconds 10^9 (1,000,000,000) => 14.415 seconds