r/algorithms • u/Valdemar216 • 6d ago
Research/Papers Prime prism algorithm
8 channels prime harvesting. Takes only O(sqrt(n)) of space instead of regular O(n). 2-3 times faster than Atkin and Sundaram. To see live: https://primeprism.replit.app
2
Upvotes
1
u/bartekltg 3d ago
Nice.
But this is just well optimized Eratosthenes. And most of the tricks are widely used.
Using a bit per number. Wheel. Not storing "wheeled out" bits (but I have to say, I only ever skipped even). Starting from p^2 is essentially required. Just like stopping when p^2 reach n
I love the trick with spreading p*n into mod 30 "lanes" so you do not need to look up position inside the byte each time (and that this is a byte seems nice).
The other table is also misleading. Segmented Eratosthenes is also a very widely know modification. Even freaking wiki mentions it. Your table suggest your version is the only one that have O(sqrt(n)) memory.
Comparing your algorithm to unoptimized at all Eratosthenes isn't a great recommendation.
This is one of the trap when telling LLMs to make you a presentations. They mix your idea with all the nice tricks better implementations use and even some obvious one, and present them all as important and revolutionary;-)
Also. 10^7 is a very low cap. At that point most people wont even care about segmented versions.