Talk:Sieve of Eratosthenes

message: Where exactly is the reference to the bit complexity being  O(n (\log n) (\log \log n)) ?
I checked the journal and I was unable to find where this was stated.
I was unable to find anything online, yet I calculated it to be O(2^nlog(log(2^n)))
Bekamancer (talk) 01:08, 7 March 2015 (UTC)
replies: text: Sieve of Eratosthenes#Algorithm complexity says "calculating all primes below n" and not n-bit primes so your 2n is certainly not needed. Then you are just missing a log n factor which probably comes from numbers below n having O(log n) bits. I haven't read the reference. PrimeHunter (talk) 01:31, 7 March 2015 (UTC)
thread_title: Bit Complexity

message: As I remember, the Sieve of Eratosthenes was a popular benchmark for early microcomputers. I thought I might find that discussed here. (Well, possibly.)  It seems not to be. I wanted to reference it from the MIPS page. Gah4 (talk) 09:02, 13 August 2016 (UTC)
replies: text: It was commonly used as a benchmark.  Bubba73 You talkin' to me? 15:57, 13 August 2016 (UTC)
thread_title:  Benchmark 

message: While improving greatly on various aspects of typographic style (thank you for that!), a recent edit by an IP user 81.129.155.32 also destroyed the carefully created visual layout of pseudocode snippets and examples throughout the whole article. 
Please don't do that without discussing it here and reaching a consensus first. Thanks. WillNess (talk) 10:12, 24 January 2017 (UTC)
thread_title:  Visual layout 

message: A recent revert has the above as its edit summary.  While this might be true, it is discouraging to new editors. Too many of those, and someone will stop trying.  Is it possible to put somewhere else in the article?  Or change such that it does make a useful addition? It looks like someone who really does understand the subject, not a random, inappropriate, edit.  Gah4 (talk) 20:44, 6 April 2017 (UTC)
thread_title:  ''(Undo good faith edit that doesn't belong in this subsection. Complexity is already discussed elsewhere in the article. Passing mention of another incremental algo is enough, no need for _its_ deep analysis.)'' 

message: When the animation marks multiples of 3 in green, it doesn't mark the number 6 in green. You could argue this is because 6 is already marked red as a multiple of 2. But the animation then marks other multiples of 3 in green even when they have already been marked in red as a multiple of 2 (e.g. 18, 48, 54, 96). It feels like the animation should mark 6 in green when marking multiples of 3. — Preceding unsigned comment added by 62.190.148.115 (talk) 18:24, 18 September 2017 (UTC)
replies: text: The caption says "including optimization of starting from prime's square". That means the multiples of 2 are marked from 22 = 4 (which makes no difference), multiples of 3 are marked starting from 32 = 9, multiples of 5 are marked from 52 = 25, and multiples of 7 from 72 = 49. Multiples below the square have always been marked by a smaller factor. Clicking the image leads to :File:Sieve of Eratosthenes animation.gif which also explains it. PrimeHunter (talk) 18:46, 18 September 2017 (UTC)
replies: text: You probably meant "Multiples below the square have already been marked by a smaller factor." Just pointing this out for the benefit of future readers here. WillNess (talk) 17:51, 29 April 2018 (UTC)
thread_title:  Animation inconsistent : Does not mark 6 in green when marking multiples of 3 

message: Hi,
It says in the segmented sieve section that the segment size delta should be chosen less than or equal to sqrt(n). The issue is that then the sieve doesn't find prime factors between delta and sqrt(n) in later segments. Shouldn't it be greater than sqrt(n) instead?  — Preceding unsigned comment added by Ovinus Real (talk • contribs) 06:29, 13 July 2020 (UTC)
replies: text: If \Delta\ge \sqrt n, all primes whose multiples must be considered belong to the first segment. Otherwise, primes in other segments must be included in "found so far". I have edited  the article for clarifying this. D.Lazard (talk) 10:02, 13 July 2020 (UTC)
thread_title:  Correction in Segmented Sieve 

message: It is unclear what the tables are trying to show in Computational analysis and Algorithmic Complexity. "following is a table showing the actually measured number of operations for a practical implementation of the sieve of Eratosthenes as compared to the number of operations predicted from the above expression" so it doesn't even show the implementation? How exactly is wheel factorization used to optimize the sieve?
--Abstractsail (talk) 07:08, 3 September 2020 (UTC)
thread_title:  The tables in Computational analysis and Algorithmic complexity make no sense 

message: I skimmed the given reference http://research.cs.wisc.edu/techreports/1990/TR909.pdf and it don't see any mention of Euler. Anyhow clearly Euler used the techniques for proofs and not as a computer algorithm to generate primes in linear time (I don't think time complexity was ever his concern in a math proof). So I don't know where the name actually comes from. Wqwt (talk) 20:27, 29 October 2021 (UTC)
replies: text: this used to be called someth like "the version of sieve in Euler's proof of zeta function", and then some editor just shortened it. There was much discussion of this version in haskell-cafe around 2010 where that short name was explicitly used, if that counts for anything. (apologies for the typos, if any) -- WillNess (talk)
(and the date is: ) WillNess (talk) 15:14, 28 May 2022 (UTC)
thread_title:  Naming of linear sieve as "Euler sieve" 

message: Both the animation and pseudo code mention that they include optimization (starting from prime squares). The argument there being all number smaller than prime squared have already been marked. It then goes and marks prime^2, prime^2 + prime, prime^2 + 2 * prime, ... but half of those numbers are even. Another common optimization is therefore to mark only prime^2, prime^2 + 2 * prime, prime^2 + 4 * prime, ... for any prime > 2. Taking this one step further is to exclude all even numbers from the array of booleans in the first place:
 algorithm Sieve of Eratosthenes is
     input: an integer n > 1.
     output: all prime numbers from 2 through n.
 
     let A be an array of Boolean values, indexed by integers 1 to n / 2,
     initially all set to true.
     
     for i = 3, 5, 7, 9, ..., not exceeding  do
         if A[i / 2] is true
             for j = i2, i2+2i, i2+4i, i2+6i, ..., not exceeding n do
                 A[j / 2] := false
 
     return all i <= n such that i == 2 or i is odd and A[i / 2] is true.
Apart from saving the time to mark all even numbers it also saves half the memory and is therefore a common optimization too.
: yes this is mentioned in the article. But we also must keep it simple. So it's a balancing act. -- WillNess (talk)
(here's the sig with the date, IIRC how to do it) WillNess (talk) 15:13, 28 May 2022 (UTC)
replies: text: That's a good optimization. You can just mention sieving by skipping evens. Further simple optimizations are mentioned at https://cp-algorithms.com/algebra/sieve-of-eratosthenes.html#sieving-by-the-odd-numbers-only  Wqwt (talk) 05:10, 25 August 2022 (UTC)
replies: text: it is mentioned, in Overview. WillNess (talk) 14:52, 3 October 2022 (UTC)
thread_title:  Missed optimization in animation and pseudo code