|
|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1280 (0x500)
Types: TextFile
Names: »PRIMES.PAS«
└─⟦291d4fa1c⟧ Bits:30003931/PolyPascal_v3.11-ccpm.imd Disketter indleveret af Steffen Jensen (Piccolo/Piccoline)
└─⟦this⟧ »PRIMES.PAS«
└─⟦74e5ee6fb⟧ Bits:30002683 PolyPascal-86 v. 3.11 - Piccoline
└─⟦74e5ee6fb⟧ Bits:30003934 SW1402 PolyPascal v3.11 (dk) til Piccoline
└─⟦this⟧ »PRIMES.PAS«
PROGRAM primes; æ$R-å
æ This program will calculate and display all prime numbers å
æ between 1 and 30000. The algorithm of the program is to start å
æ out with an array containing representatives for all odd num- å
æ bers between 3 and 29999. Starting from 3 and working upwards å
æ each odd number is then tested. If a number is still a member å
æ of the list when it is tested, it is a prime number, and thus å
æ it is printed, and all odd multiples of the number are elimi- å
æ nated from the list. As can be expected, the program is quite å
æ slow on calculating the very first primes, but from then on å
æ it gets faster and faster. Note that 1 and 2 are assumed to å
æ be primes, and not actually calculated. å
CONST
max2 = 15000; æmaxprime/2å
max3 = 10000; æmaxprime/3å
VAR
i,j,k: integer;
test: ARRAYÆ2..max2Å OF boolean;
BEGIN
write(1:8,2:8);
FOR i:=2 TO max2 DO testÆiÅ:=true;
FOR i:=2 TO max2 DO
IF testÆiÅ THEN
BEGIN
j:=i+i-1; write(j:8);
IF j<max3 THEN
BEGIN
k:=i+j;
WHILE k<=max2 DO
BEGIN
testÆkÅ:=false; k:=k+j;
END;
END;
END;
writeln;
END.