|
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 - download
Length: 1280 (0x500) Types: TextFile Names: »PRIMES.PAS«
└─⟦08ea08c61⟧ Bits:30003924 PolyPascal programmer └─ ⟦this⟧ »PRIMES.PAS« └─⟦42acf21c3⟧ Bits:30005716 PolyPascal-80 v. 3.10 (RC703) └─ ⟦this⟧ »PRIMES.PAS« └─⟦6367c43c0⟧ Bits:30004325 PolyPascal vers. 3.10 for Butler └─ ⟦this⟧ »PRIMES.PAS« └─⟦725a95225⟧ Bits:30003287 PolyPascal v. 3.10 med eksempler for RC700 └─ ⟦this⟧ »PRIMES.PAS« └─⟦bffadc512⟧ Bits:30003938 SW1502 PolyPascal 3.10 (dk) til RC Partner └─⟦bffadc512⟧ Bits:30004539 SW1402 PolyPascal v3.10 (dk) til Piccoline └─ ⟦this⟧ »PRIMES.PAS« └─⟦f03928158⟧ Bits:30005922 PolyPascal 3.10 (RC700) └─ ⟦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. «eof»