3 ms·
I know the point of this blog post is to benchmark languages with a naive use case, but for those interested, there are many faster algorithms designed for dete
by vortico 11y ago
I know the point of this blog post is to benchmark languages with a naive use case, but for those interested, there are many faster algorithms designed for deterministically or probabilistically checking the primality of a number, and even faster ones for computing the number of primes up to n. Recently a modified Lagarias-Odlyzko method was used to compute the number of primes up to 10^25, although I believe it requires the Riemann Hypothesis.
Approximations to this computation are even more fun: Asymptotically, this function tends to x/ln(x), or more accurately to the integral 1/ln(x) dx from x=2 to n, whose asymptotic expansion is x/ln(x) + 1!x/(ln(x))^2 + 2!x/(ln(x))^3 + ...