Primes by Trial Division - UCB LOGO

15 February 2018

UCB LOGO supports arrays, and has an infix + operator.

to primes :n
(local "primes "count "found "i)
make "primes array :n
make "count 2
make "found 0
label "continue
catch "notprime [
  make "i 1
  repeat :found [
    if (remainder :count item :i :primes) = 0
      [ throw "notprime ]
      [ make "i (1 + :i) ]
    ]
  print :count
  make "found (1 + :found)
  setitem :found :primes :count
]
make "count (1 + :count)
if :found < :n [ go "continue ]
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 LOGOs

Acornsoft Logo

DR LOGO

LCSI LogoWriter

Logotron LOGO

Terrapin Logo PLUS

TI LOGO

UCB LOGO