Dijkstra's Prime Number Algorithm
heinrichhartmann.com
heinrichhartmann.com
The same holds for the Sieve of Eratosthenes [1]
And it uses no divisions.
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Euler.27...
I still find it remarkable, that you can avoid divisions, while not to computing all multiples up-front and marking the results in a large table.
Can you express the number in terms of the quotient and remainder?
Using this expression write an algorithm that outputs the quotient and remainder using only addition, multiplication and checking equality with integers.
I think doing this would make the algorithm seem less surprising.
https://www.quora.com/Is-there-a-prime-between-every-natural...
Each prime generates a spacing sequence to find future primes, each prime is effectively casting a new periodic wave function. 2 produces a wave that hits all even numbers. 3 produces a wave that hits every 6 numbers (2 already gets everything else.) 5 does every {20,10}, etc...
You can see the process of generating the sieve waveform, or more technically, the prime gaps, here:
http://math.stackexchange.com/questions/311610/modified-eule...
Look at the 2nd answer, it explains the process. Remember, all prime numbers do, is cast a waveform onto the existing sieve waveform. Just chaotic interference. Division as an immediate reaction to primes is moreso because primes are taught pretty poorly. As mystic nuggets. Rather than chaotic interference.
With friendly intentions, I have to tell you that you risk sounding like a math crank.
Wheres the issue with the method of mirroring and partitioning I discussed? Do you have something better than wont involve division?
Also, there is a lot of merit in understanding how the sieve works because gap sequences work until the next prime squared. As the primes tend toward infinity, the sieve matches all primes. Its a valid way to study primes aside from the attacks on the Zeta function
Basically I am encouraging you to discuss this in a way or in a context in which people will engage more readily with your ideas, either to accept or reject them. HN is not full of number theorists.
Edit: This is a case where textual communication is really inadequate to determine the seriousness and, dare I say it, credibility of an interlocutor.
You misunderstand me. I don't claim that the dRRS is a magic bullet. But it certainly isn't crank..
http://www.kylem.net/stuff/sieve_eratosthenes.html
I don't completely understand it yet, but I think the Dijkstra version might have optimized the structure which contains the multiples of known primes, where I just put it into a dictionary.
* I initially saw it in a paper about how the Sieve is generally implemented incorrectly in Haskell, but I made a small Python generator implementation.
https://wiki.haskell.org/Prime_numbers
And a long list of algorithms. Many of which are surprising and probably not that efficient. The first few are:
https://wiki.haskell.org/Prime_numbers_miscellaneous#Prime_W...
Efficiency is kind of a relative issue, since you don't know the job beforehand or which one would be optimal
let f='.';o c(x:y)=x:c y;z c(x:y)=f:c y;p n='p':ap fix p(o.n)in f:f:p z
defining the `bitmap' of prime numbers ..pp.p.p...p.p...p.p...p.....p.p.....p...p.p...p.. ...
while avoiding arithmetic altogether.... no wait: It's corrected now. ;)
In fact, there's an increasing loss as we optimize the constant factor in the sieve's O(x).
To wit, Dijkstra's algorithm takes 776MB to store all 203280221 primes under 2^32 at 4 bytes per prime.
A simple version of Eratosthenes' sieve, using 1 bit per odd number, takes 2^31 bits, which is only 256MB.
A more streamlined sieve like the one on my webpage at
http://tromp.github.io/pearls.html
implicitly filters out multiples of 2, 3, and 5, leaving only 8 potential primes in every 30 consecutive integers, conveniently fitting in a byte, for a total of 137MB.
(for some reason, compiling with nonzero optimization gives a gcc 4.8.5 internal compiler error on my SUSE Linux box)