home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / interpre / p_pascal / samples / primes.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-05-03  |  428 b   |  24 lines

  1. (*$c+*)
  2. PROGRAM primes;
  3. VAR n, nd, odd, p, pc : INTEGER;
  4. BEGIN
  5.  write('How many primes? ');
  6.  read(n); writeln(2 : 1); writeln(3 : 1);
  7.  pc := 2; p := 3;
  8.  WHILE pc < n DO
  9.   BEGIN
  10.    REPEAT
  11.     nd := 0; p := p + 2; odd := 3;
  12.     WHILE odd < p DO
  13.      BEGIN
  14.       IF p DIV odd * odd = p THEN
  15.        nd := nd + 1;
  16.       odd := odd + 2
  17.      END;
  18.    UNTIL nd <= 0;
  19.    writeln(p : 1);
  20.    pc := pc + 1
  21.   END
  22. END.
  23.  
  24.