Sieve of Eratosthenes: Difference between revisions
Content deleted Content added
Line 8,296: | Line 8,296: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
===Basic sieve of array of booleans=== |
===Basic sieve of array of booleans=== |
||
<lang futurebasic> |
<lang futurebasic>window 1, @"Sieve of Eratosthenes", (0,0,720,300) |
||
include "ConsoleWindow" |
|||
begin globals |
begin globals |
||
dynamic gPrimes(1) as Boolean |
|||
end globals |
end globals |
||
local fn SieveOfEratosthenes( n as long ) |
local fn SieveOfEratosthenes( n as long ) |
||
long i, j |
|||
for i = 2 to n |
for i = 2 to n |
||
for j = i * i to n step i |
for j = i * i to n step i |
||
gPrimes(j) = _true |
gPrimes(j) = _true |
||
next |
next |
||
if gPrimes(i) = 0 then print i |
if gPrimes(i) = 0 then print i, |
||
next i |
next i |
||
kill gPrimes |
kill gPrimes |
||
end fn |
end fn |
||
fn SieveOfEratosthenes( 100 ) |
fn SieveOfEratosthenes( 100 ) |
||
</lang> |
|||
HandleEvents</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |