Category:Action! Sieve of Eratosthenes: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "== Sieve of Eratosthenes == The following module marks prime numbers using Sieve of Eratosthenes algorithm. <lang Action!>MODULE PROC Sieve(BYTE ARRAY primes INT count) C...")
 
Line 1: Line 1:
== Sieve of Eratosthenes ==
== Sieve of Eratosthenes ==

=== SIEVE.ACT ===


The following module marks prime numbers using Sieve of Eratosthenes algorithm.
The following module marks prime numbers using Sieve of Eratosthenes algorithm.

Revision as of 22:55, 14 November 2021

Sieve of Eratosthenes

SIEVE.ACT

The following module marks prime numbers using Sieve of Eratosthenes algorithm.

<lang Action!>MODULE

PROC Sieve(BYTE ARRAY primes INT count)

 CARD i,j
 SetBlock(primes,count,1)
 primes(0)=0 primes(1)=0 i=2
 WHILE i<count
 DO
   IF primes(i)=1 THEN
     FOR j=2*i TO count-1 STEP i
     DO
       primes(j)=0
     OD
   FI
   i==+1
 OD

RETURN

MODULE</lang>