Primes by Trial Division - VisualAge Smalltalk

12 January 2018

Again, more differences in required formatting for the FileIn task. The method definition is the same as the other Smalltalk systems.

Object subclass: #Benchmark
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''!

!Benchmark publicMethods !

findPrimes: n
    "Transcript show: (Time millisecondsToRun: [ Transcript show: ((Benchmark new) findPrimes: 10000) printString; cr. ]) printString; cr."
    | count primes |
    count := 3.
    primes := OrderedCollection with: 2.
    [ primes size < n ] whileTrue: [
        primes detect: [ :prime | count \\ prime = 0 ] ifNone: [ primes add: count ].
        count := count + 1. ].
    ^primes! !

Benchmark initializeAfterLoad!

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 Smalltalks

Little Smalltalk

ObjectWorks

Smalltalk/V

Smalltalk-80

VisualAge Smalltalk