*/
Love this site? Hate it? Leave us some comments.
*/

View SAMPLES\PRIMES.PAS

Portable ISO Standard Pascal in C, version 3.8

Submitted By: WEBMASTER
Rating: starstarstarstar (Rate It)


(*$c+*)
PROGRAM primes;
VAR n, nd, odd, p, pc : INTEGER;
BEGIN
 write('How many primes? ');
 read(n); writeln(2 : 1); writeln(3 : 1);
 pc := 2; p := 3;
 WHILE pc < n DO
  BEGIN
   REPEAT
    nd := 0; p := p + 2; odd := 3;
    WHILE odd < p DO
     BEGIN
      IF p DIV odd * odd = p THEN
       nd := nd + 1;
      odd := odd + 2
     END;
   UNTIL nd <= 0;
   writeln(p : 1);
   pc := pc + 1
  END
END.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.