Primes by Trial Division - VS Pascal

17 April 2020

IBM VS Pascal for the S/370 requires modifications for console I/O.

PROGRAM nPrimes;

(* CONST NumPrimes = 100; *)
CONST NumPrimes = 1000;
(* CONST NumPrimes = 10000; *)


VAR TTYout : TEXT;
    Count, Index, Found : INTEGER;
    Primes : ARRAY [1..NumPrimes] OF INTEGER;
    
BEGIN

	TermOut(TTYout);

	Found := 0;
	Count := 2;
	
	WHILE Found < NumPrimes DO
	BEGIN

		Found := Found + 1;
		Primes[Found] := Count;
		WriteLn(TTYout, Count);
		Count := Count + 1;
		
		Index := 1;
		REPEAT
			IF Count MOD Primes[Index] = 0 THEN
			BEGIN
				Count := Count + 1;
				Index := 0;
			END;
			Index := Index + 1;
		UNTIL Index > Found;
	
	END;
	
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 Pascal Family

Ada-83

Ada-95

Modula-2

TopSpeed Modula-2

Oberon

Oberon-2

Active Oberon

Pascal

VS Pascal