home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
239.img
/
TPROF10.ZIP
/
TFEXMPL3.ZIP
/
PRIME0PA.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-05-07
|
1KB
|
48 lines
{ Copyright (c) 1990, Borland International }
program Prime0PA;
const
MaxPrimes = 1000;
type
PrimeArray = array[1..1000] of Integer;
var
Primes : PrimeArray;
CurPrime, LastPrime : Integer;
J : Integer;
GetOut : Boolean;
begin
Primes[1] := 2;
Primes[2] := 3;
LastPrime := 2;
CurPrime := 3;
Writeln('Prime 1 = ', Primes[1]);
Writeln('Prime 2 = ', Primes[2]);
while CurPrime < MaxPrimes do
begin
GetOut := False;
J := 1;
while (J <= LastPrime) and (not GetOut) do
begin
if (CurPrime mod Primes[J]) = 0 then
begin
CurPrime := CurPrime + 2;
GetOut := True;
end
else
Inc(J);
end; { while }
if J > LastPrime then
begin
Inc(LastPrime);
Writeln('Prime ', LastPrime, ' = ', CurPrime);
Primes[LastPrime] := CurPrime;
CurPrime := CurPrime + 2;
end; { if }
end; { while }
end. { Prime0 }