Primes by Trial Division - IBM PC BASIC

15 August 2016

The IBM PC BASIC / Microsoft GW-BASIC version is identical to the Applesoft reference version apart from its taking advantage of the MODulus function available in this BASIC.

Even though this BASIC runs on a modern PC and would easily be fast enough to give a sensible result for n=10000, the integer type is a 16-bit signed quantity. It cannot express a result larger than 32768 and crashes after finding the 3512th prime.

 1 GOTO 10
 5 COUNT = COUNT + 1
 6 GOTO 50
 10 DIM PRIMES(99)
 20 PRIMES(0) = 2
 25 PRINT PRIMES(0)
 30 COUNT = 3
 40 FOR FOUND = 1 TO 99
 50 FOR INDEX = 0 TO (FOUND - 1)
 60 IF (COUNT MOD PRIMES(INDEX)) = 0 THEN GOTO 5
 70 NEXT INDEX
 80 PRINT COUNT
 90 PRIMES(FOUND) = COUNT
 100 COUNT = COUNT + 1
 110 NEXT FOUND
 120 END

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

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

Structured BASIC

Amiga BASIC

Dartmouth True BASIC

Microsoft QuickBASIC

Microware Basic09

Topaz S-BASIC