eratos.pp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {****************************************************************************
  2. $Id$
  3. Copyright (c) 1993,94 by Florian Kl„mpfl
  4. Translated By Eric Molitor ([email protected])
  5. ****************************************************************************}
  6. { Demonstration Program in FPKPascal }
  7. { Calculates all Prime Numbers from 1 to max }
  8. program eratosthenes;
  9. const
  10. max = 1000000;
  11. var
  12. a : array[1..max] of boolean;
  13. procedure eratos;
  14. var
  15. i,j : longint;
  16. begin
  17. a[1]:=false;
  18. for i:=1 to max do
  19. a[i]:=true;
  20. for i:=2 to max div 2 do
  21. for j:=2 to max div i do
  22. a[i*j]:=false;
  23. writeln;
  24. for i:=1 to max do
  25. if a[i] then
  26. write(i:8);
  27. writeln;
  28. end;
  29. begin
  30. write('Calculating the Prime Numbers from 1 to ',max,'...');
  31. eratos;
  32. end.
  33. {
  34. $Log$
  35. Revision 1.3 1998-04-06 12:23:21 pierre
  36. * log problem
  37. Revision 1.2 1998/04/06 12:17:00 pierre
  38. * made array a global to avoid stack overflow
  39. }