Category : BASIC Source Code
Archive   : QBFAQR01.ZIP
Filename : ERATOS.BAS

 
Output of file : ERATOS.BAS contained in archive : QBFAQR01.ZIP
'Date: 03-23-92 (22:35)
'From: BRENT ASHLEY
'---------------------------------------------------------------------------
'Here's a variation on a program I entered in a primes contest about a
'year ago.


DEFINT A-Z
' initialise array to zeros
DIM flags(10000)

max = 10000
rootmax = SQR(max)
NonPrime = -1

' show 2 as prime
PRINT " 2 ";

' flag all non-primes
FOR Num = 3 TO rootmax STEP 2

' check for prime
IF NOT flags(Num) THEN

' print prime number
PRINT USING " ###### "; Num;

' flag all multiples
multiple = 2 * Num
WHILE multiple <= max
flags(multiple) = NonPrime
multiple = multiple + Num
WEND
END IF

' flag even numbers
flags(Num + 1) = NonPrime
NEXT

END ' of program


  3 Responses to “Category : BASIC Source Code
Archive   : QBFAQR01.ZIP
Filename : ERATOS.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/