DataMuseum.dk

Presents historical artifacts from the history of:

RC4000/8000/9000

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RC4000/8000/9000

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦e401d57aa⟧ TextFile

    Length: 768 (0x300)
    Types: TextFile
    Names: »prime1tx    «

Derivation

└─⟦01e83a425⟧ Bits:30008166 Bånd med SW8010 og SW8500 source code
    └─⟦75ff9bef3⟧ 
        └─⟦this⟧ »prime1tx    « 

TextFile


program prime1 (input, output);

const
  n=500; 

type
  positive = 1..maxint;

var
  sieve, primes       : set of 2..n;
  nextprime, multiple : positive;

begin æinitializeå
  sieve := Æ2..nÅ; primes := ÆÅ; nextprime := 2;
  
  repeat æ find next primeå
    while not (nextprime in sieve) do
      nextprime := succ (nextprime);

    primes := primes + ÆnextprimeÅ;
    multiple := nextprime;

    while multiple <= n do æeliminateå
    begin
      sieve := sieve - ÆmultipleÅ;
      multiple := multiple + nextprime;
    end;

  until sieve = ÆÅ;

  nextprime := 2;
  repeat
    nextprime := succ (nextprime);
    if (nextprime in primes) then
      writeln (nextprime:6);
  until nextprime >= n;
end.
▶EOF◀