New answers tagged

0

I am not a javascript developer so most of this answer will focus on the algorithm rather than specific language usage. There are some simple algorithmic improvements you can make without changing your entire algorithm. Firstly, there is a simple one - do you need to check every single number under n/2? Once you've checked if 2 is a divisor, there is no need ...


0

Testing every integer using trial division is probably the slowest way to find primes. Change the algorithm to use one of the standard prime number sieves (e.g. Sieve of Eratosthenes).


Top 50 recent answers are included