File: sieve

package info (click to toggle)
brandy 1.23.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,268 kB
  • sloc: ansic: 39,421; makefile: 91; sh: 1
file content (28 lines) | stat: -rw-r--r-- 492 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
REM Sieve of Eratosthenes Prime Number Program
:
size%=10000
iterations%=10
:
DIM flags%(size%)
:
T=TIME
PRINT;iterations%;" iterations."
FOR C%=1 TO iterations%
  PRINT"Doing ";C%
  count%=0
  flags%()=TRUE
  FOR I%=0 TO size%
    IF flags%(I%) THEN
      prime%=I%+I%+3
      K%=I%+prime%
      WHILE K%<=size%
        flags%(K%)=FALSE
        K%+=prime%
      ENDWHILE
      count%+=1
    ENDIF
  NEXT
NEXT
PRINT"There are ";count%;" primes"
PRINT"Time taken=";(TIME-T)/100;" seconds"
END