2
Python 3
Why am I using Python for fastest-code >_>
8.89 sec for 1,000,000.
def f(a,b):
primes = [True]*(a+1)
primes[0] = primes[1] = False
for p in range(2,a+1):
if primes[p]:
for j in range(p**2,a+1,p):
primes[j] = False
primes = [i for i in range(2,a+1) if primes[i]]
count = 0