home *** CD-ROM | disk | FTP | other *** search
/ Amiga Computing 57 / ac057a.adf / Demos / sieve.bas < prev    next >
BASIC Source File  |  1988-12-19  |  485b  |  28 lines

  1. REM $EVENT OFF
  2. REM $OPTION a-o-x-n-
  3. defint a-z
  4. 10 PRINT "BYTE SIEVE, 7000 numbers done 5 times"
  5. t!=timer
  6. 20 SIZE=7000
  7. 30 DIM FLAGS(7001)
  8.    for j=1 to 5
  9. 40 ACOUNT=0
  10. 50 FOR I=0 TO SIZE
  11. 60 FLAGS(I)=1
  12. 70 NEXT I
  13. 80 FOR I=0 TO SIZE
  14. 90 IF FLAGS(I)=0 THEN GOTO 170
  15. 100 PRIME=I+I+3
  16. 110 K=I+PRIME
  17. 120 IF K>SIZE THEN GOTO 160
  18. 130 FLAGS(K)=0
  19. 140 K=K+PRIME
  20. 150 GOTO 120
  21. 160 ACOUNT=ACOUNT+1
  22. 170 NEXT I
  23.     next j
  24. t!=timer-t!
  25. 180 PRINT ACOUNT;"primes found"
  26. print "in";t!/5;"seconds per iteration"
  27.  
  28.