home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fpkbin99.zip / DEMOS / ERATOS.PAS next >
Pascal/Delphi Source File  |  1998-10-12  |  897b  |  40 lines

  1. {****************************************************************************
  2.  
  3.                    Copyright (c) 1993,94 by Florian Klämpfl
  4.                    Translated By Eric Molitor (emolitor@freenet.fsu.edu)
  5.  
  6.  ****************************************************************************}
  7.  
  8. { Demonstration Program in FPKPascal }
  9. { Calculates all Prime Numbers from 1 to max }
  10.  
  11. program eratosthenes;
  12.  
  13.   const
  14.      max = 1000000;
  15.  
  16.   procedure eratos;
  17.  
  18.     var
  19.        a : array[1..max] of boolean;
  20.        i,j : longint;
  21.  
  22.     begin
  23.        a[1]:=false;
  24.        for i:=1 to max do
  25.          a[i]:=true;
  26.        for i:=2 to max div 2 do
  27.          for j:=2 to max div i do
  28.            a[i*j]:=false;
  29.        writeln;
  30.        for i:=1 to max do
  31.          if a[i] then
  32.            write(i:8);
  33.        writeln;
  34.     end;
  35.  
  36.   begin
  37.      write('Calculating the Prime Numbers from 1 to ',max,'...');
  38.      eratos;
  39.   end.
  40.