0

Are there any algorithms for generating prime numbers...

... other than sieves and trial division algorithms. I'm looking for the fastest (so far it's Sieve of Eratosthenes without any optimization)

21st Nov 2021, 2:31 PM
Hilary
Hilary - avatar
2 Respostas
0
SoloProg that algorithm is the trial division algorithm. It also needs some extra optimization. That is, you don't have to divide the numerator with a denominator all the way to <<denominator == numerator>>, that is [denominator = 2; denominator <= n; denominator++]. The denominators can stop at the square root of n. You'll get the same primes, with some considerable speed. Thanks anyway.
6th Dec 2021, 4:09 PM
Hilary
Hilary - avatar