Primes by Trial Division - Tcl

4 March 2018

set n $argv;
set found 0;
set count 2;

while {$found < $n} {

  set index 0;
  while {$index < $found} {
    if {$count % $primes($index) == 0} {
      set index 0;
      set count [expr {$count + 1}];
    } else {
      set index [expr {$index + 1}];
    }
  }

  puts $count;
  set primes($found) $count;
  set count [expr {$count + 1}];
  set found [expr {$found + 1}];

}

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 Implementations

BCPL

perl

REXX

ruby

Tcl