'=========================================================================== ' Subject: FIND PRIME NUMBERS UP TO 31991 Date: 05-11-00 (00:37) ' Author: Dieter Folger Code: QB, QBasic, PDS, PB ' Origin: folger@bnv-bamberg.de Packet: ALGOR.ABC '=========================================================================== '---------------------------------- 'PRIME.BAS for QBasic or Powerbasic 'Finds the prime numbers up to 31991 'and writes them to PRIME.DAT '---------------------------------- DEFINT A-Z DIM p(32000) OPEN "PRIME.DAT" FOR OUTPUT AS #1 FOR i = 3 TO SQR(32000) STEP 2 FOR j = i * i TO 32000 STEP 2 * i p(j) = 1 NEXT j NEXT i PRINT #1, 2 'first prime number FOR i = 3 TO 32000 STEP 2 IF p(i) = 0 THEN PRINT #1, i NEXT i CLOSE PRINT "Done" END