Primes by Trial Division - Microsoft QBasic

17 August 2016

While Microsoft QBasic does allow programs with line numbers, idiomatically one is meant not to. So this version does not have them. Stack exhaustion was a problem for QBasic with the way the Applesoft version uses FOR/NEXT, so program flow has improved slightly as a side effect of dealing with that. The MODulus function is put to use as well.

       SUB primes (n AS INTEGER)
         count = 2
         found = 0
         index = 0
         DIM prime(n - 1)
         DO WHILE found < n
           PRINT count
           prime(found) = count
           found = found + 1
NOTPRIME:  count = count + 1
           index = 0
           DO
             v = count MOD prime(index)
             index = index + 1
           LOOP UNTIL v = 0 OR index = found
           IF v = 0 THEN GOTO NOTPRIME
         LOOP
       END SUB

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026

Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Primes Benchmark Source

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Primes Benchmark Results

Structured BASIC

Amiga BASIC

Dartmouth True BASIC

Microsoft QuickBASIC

Microware Basic09

Topaz S-BASIC

Other BASICs

Applesoft BASIC

Atari 2600 BASIC

BBC BASIC

Commodore BASIC

DRI Personal BASIC

HP BASIC/V

IBM 5100 BASIC

IBM PC BASIC

PICK/BASIC

Rocky Mountain BASIC

Sinclair ZX80 BASIC

Spectravideo Compumate

TI 99/4 BASIC

TRS-80 Level 1 BASIC

V-Tech Laser 50

VAX BASIC