Primes by Trial Division - Oberon-2

1 October 2017

Oberon-2 (finally!) adds the ability to have an open array declared outside of a formal parameter.

MODULE Benchmark;

IMPORT Oberon, Texts, Out;

	PROCEDURE pCalc (VAR NumPrimes : LONGINT);
	VAR Count, Index, Found : LONGINT;
		Primes : POINTER TO ARRAY OF LONGINT;
	BEGIN
		NEW(Primes, NumPrimes);
		
		Found := 0;
		Count := 2;
		
		WHILE Found < NumPrimes DO
		
			Primes[Found] := Count;
			Out.Int(Count, 6);
			Out.Ln;
			INC(Count);
			INC(Found);
			
			Index := 0;
			REPEAT
				IF Count MOD Primes[Index] = 0 THEN
					INC(Count);
					Index := 0
				END;
				INC(Index);
			UNTIL Index = Found
		END;
	
	END pCalc;

	PROCEDURE nPrimes*;
	VAR Arg : Texts.Scanner;
	BEGIN
		Texts.OpenScanner(Arg, Oberon.Par.text, Oberon.Par.pos);
		Texts.Scan(Arg);
		pCalc(Arg.i)
	END nPrimes;

END Benchmark.

Benchmark.nPrimes 10000 ~

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 Pascal Family

Ada-83

Ada-95

Modula-2

TopSpeed Modula-2

Oberon

Oberon-2

Active Oberon

Pascal

VS Pascal