0

I'm trying to come up with ways to write Sieve of Eratosthenes in Octave that vectorize as much as possible (ie minimizing the number of times iterating over the for-loop/while-loop/recursive call)

I found one that requires only O(log(log(n))) iterations inside the for-loop, but the big-O running time (and also space) is O(n^(5/4)/log(n)) so it's arguably not the Sieve of Eratosthenes

Now I think I have one with the usual running time O(nlog(log(n))) and only O(log(n)) iterations, but I want to see if someone else comes up with a better solution.

You're asking us to come up with an improvement to an algorithm that dates back to ancient Greece? You might have better luck posting your code and asking for suggestions for improvement. – Mr. Llama – 2013-03-13T20:28:53.233

I'm not asking for a big-O running-time improvement. I'm just saying can you write a SOE that's better vectorized for Octave? – dspyz – 2013-03-13T22:07:51.907

1Is this really in a form appropriate for CodeGolf.SE? Perhaps it would be better on CodeReview? – dmckee --- ex-moderator kitten – 2013-03-18T18:02:21.293