Sieve of Eratosthenes: Difference between revisions

Content deleted Content added
Added Woma Example
Line 1,754: Line 1,754:
duplicate entries are omitted. Thus, a slightly transformed Sieve of Sundaram is what Eratosthenes' Sieve becomes upon applying all
duplicate entries are omitted. Thus, a slightly transformed Sieve of Sundaram is what Eratosthenes' Sieve becomes upon applying all
optimisations incorporated into the prior entries for QL SuperBASIC, AND by not implementing an equivalent to line 50 in them.
optimisations incorporated into the prior entries for QL SuperBASIC, AND by not implementing an equivalent to line 50 in them.
Backward-compatible on 1K ZX80s for all primes < 441 (O=10).<lang qbasic>
Backward-compatible on 1K ZX80s for all primes < 441 (O=10) after substituting ** for ^ in line 120.<lang qbasic>
10 INPUT O
10 INPUT O
15 LET Z=2*O^2+O*2
15 LET Z=2*O*O+O*2
30 DIM H(Z)
30 DIM H(Z)
40 FOR I=1 TO O
40 FOR I=1 TO O
45 LET A=2*I^2+I*2
45 LET A=2*I*I+I*2
60 FOR J=A TO Z STEP 1+I*2
60 FOR J=A TO Z STEP 1+I*2
70 LET H(J)=1
70 LET H(J)=1