home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / basic / cursor.lha / Cursor / Examples / Primes / Primes.bas < prev    next >
Encoding:
BASIC Source File  |  1992-09-02  |  543 b   |  27 lines

  1.  
  2. ' This program prints the prime-numbers from 2 to 1000 to the screen.
  3. ' The compiled program needs 16 seconds (12 seconds without PRINT-command),
  4. ' with AmigaBASIC it takes about 148 (139) seconds on my Amiga 500
  5.  
  6.  OPTION NOWINDOW,ALLPCRELATIVE
  7.  
  8.  DEFINT a-z
  9.  
  10.  SCREEN 2,640,200,1,2
  11.  WINDOW 2,"prime numbers from 2 to 1000:",,,2
  12.  
  13.  BeginTime! = TIMER
  14.  
  15.  FOR a = 2 TO 1000
  16.    FOR b = 3 TO a-1
  17.      IF a MOD b = 0 THEN NotPrim
  18.    NEXT b
  19.    PRINT a
  20. NotPrim:
  21.  NEXT a
  22.  
  23.  WINDOW 2,"time needed:"+STR$(TIMER-BeginTime!)+" s."
  24.  
  25.  WHILE INKEY$ = "" : WEND
  26.  
  27.