Quantcast
Channel: Further Optimizing a Segmented Sieve of Eratosthenes - Code Review Stack Exchange
Browsing latest articles
Browse All 2 View Live

Answer by AJNeufeld for Further Optimizing a Segmented Sieve of Eratosthenes

Python 3.8 adds math.isqrt(). Using this, you can make a much less cryptic perfect square check:high == math.isqrt(high) ** 2Memory Optimization (speed too!)Using a list of Boolean flags:numbers =...

View Article



Further Optimizing a Segmented Sieve of Eratosthenes

I've implemented a Segmented Sieve of Eratosthenes that assumes each segment is about length \$ \sqrt{N}\$ for some upper limit \$N\$.I further optimized the function by skipping all the evens when...

View Article
Browsing latest articles
Browse All 2 View Live




Latest Images