prime numbers

Pages: 12
On my PC it takes 68s with a lim of 100 000 000.

No rating, guesstimate or contemptuousness about your PC from a single measurement. Before you throw it away try this one: https://github.com/kimwalisch/primesieve/wiki/Downloads
On my PC, counting primes with it from 1..100 000 000:
Prime numbers:	5761455
Elapsed time:	0.01 sec
It wasn't about a single measurement...

And I don't say that I have the best algo to count prime numbers, it's just something i made myself.
Don't sweat it...
the best way to check isprime() for small (meaning up to a few million, using a bit per number you can stuff an awful lot into a gb or 2 of ram) is the same way you do factorial or anything else... use a lookup table.
if( primetable[value]) ...
problem solved for 0-100 for sure.
Topic archived. No new replies allowed.
Pages: 12