Sieve of Eratosthenes: Difference between revisions
Content deleted Content added
GordonBGood (talk | contribs) →Page-Segmented Odds-Only Version: Crystal, refactored to include lazy list functionality in BasePrimeArrays... |
→{{header|COMAL}}: Add implementation. |
||
Line 4,193:
GOBACK
.</lang>
=={{header|Comal}}==
{{trans|BASIC}}
<lang comal>// Sieve of Eratosthenes
input "Limit? ": limit
dim sieve(1:limit)
sqrlimit:=sqr(limit)
sieve(1):=1
p:=2
while p<=sqrlimit do
while sieve(p) do
p:=p+1
endwhile
for i:=p*p to limit step p do
sieve(i):=1
endfor i
p:=p+1
endwhile
for i:=2 to limit do
if sieve(i)=0 then print i," ",
endfor i
print</lang>
{{Out}}
<pre>
Limit? 100
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97
end</pre>
=={{header|Common Lisp}}==
|