Primes by Trial Division - BBC BASIC

14 August 2016

BBC BASIC required several changes. This BASIC has a MODulus function, array indices are 1-based instead of 0-based, and the way the Applesoft reference version jumps in and out of the inner FOR loop causes the BBC BASIC stack to be exhausted after a couple iterations. So this version uses REPEAT/UNTIL.

   10 DIM primes(100)
   20 index=1
   30 count=2
   40 found=1
   50 primes(index)=count
   60 PRINT primes(index)
   70 REPEAT
   80 count=count+1
   90 REPEAT
  100 v=(count MOD primes(index))
  110 index=index+1
  120 UNTIL v=0 OR index>found
  130 IF v=0 THEN GOTO 170
  140 PRINT count
  150 primes(index)=count
  160 found=found+1
  170 index=1
  180 UNTIL found=100

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