Category:Action! Sieve of Eratosthenes: Difference between revisions
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...") |
(→Sieve of Eratosthenes: fixed syntax highlighting) |
||
(One intermediate revision by one other user not shown) | |||
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. |
||
<syntaxhighlight lang="action!"> |
|||
<lang Action!>MODULE |
|||
MODULE |
|||
PROC Sieve(BYTE ARRAY primes INT count) |
PROC Sieve(BYTE ARRAY primes INT count) |
||
Line 22: | Line 25: | ||
RETURN |
RETURN |
||
MODULE |
MODULE |
||
</syntaxhighlight> |
Latest revision as of 22:55, 27 September 2022
Sieve of Eratosthenes
SIEVE.ACT
The following module marks prime numbers using Sieve of Eratosthenes algorithm.
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
Pages in category "Action! Sieve of Eratosthenes"
The following 32 pages are in this category, out of 32 total.