Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок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)
2 ответов
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.