Sieve of Eratosthenes: Difference between revisions

no edit summary
(→‎{{header|SASL}}: incorrect: Trial Division...)
No edit summary
Line 10,861:
17
19</pre>
 
=={{header|Yabasic}}==
<lang Yabasic>#!/usr/bin/yabasic
 
// ---------------------------
// Prime Sieve Benchmark --
// "Shootout" Version --
// ---------------------------
// usage:
// yabasic sieve8k.yab 90000
 
 
SIZE = 8192
ONN = 1 : OFF = 0
dim flags(SIZE)
 
sub main()
cmd = peek("arguments")
if cmd = 1 then
iterations = val(peek$("argument"))
if iterations = 0 then print "Argument wrong. Done 1000." : iterations = 1000 end if
else
print "1000 iterations."
iterations = 1000
end if
for iter = 1 to iterations
count = 0
for n= 1 to SIZE : flags(n) = ONN: next n
for i = 2 to SIZE
if flags(i) = ONN then
let k = i + i
if k < SIZE then
for k = k to SIZE step i
flags(k) = OFF
next k
end if
count = count + 1
end if
next i
next iter
print "Count: ", count // 1028
end sub
 
clear screen
 
print "Prime Sieve Benchmark\n"
 
main()
 
t = val(mid$(time$,10))
 
print "time: ", t, "\n"
print peek("millisrunning")</lang>
 
=={{header|zkl}}==
<lang zkl>fcn sieve(limit){
672

edits