home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISOFT.LZH / HISOFT_B.MSA / EXAMPLES / SIEVE.BAS < prev    next >
BASIC Source File  |  1987-07-27  |  546b  |  27 lines

  1. rem next line turns overflow, array checks and line numbers off
  2. rem $option a-o-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 "Took" t!/5 "seconds"
  27.