Cod sursa(job #593178)

Utilizator OpportunityVlad Negura Opportunity Data 1 iunie 2011 17:37:53
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.54 kb
program p1;
type boolean=0..1;
var a:array[2..2000000]of boolean;
    i,j,n,k:longint;
    f1,f2:text;

procedure rez;
 begin
  for i:=2 to n do
   if a[i]=0 then
              begin
               j:=i;
               inc(k);
                while j<=n do
                 begin
                  a[j]:=1;
                  inc(j,i);
                 end;
             end;
 end;


Begin
 assign(f1,'ciur.in'); reset(f1);
 assign(f2,'ciur.out'); rewrite(f2);

 readln(f1,n);
 rez;
 write(f2,k);

 close(f1); close(f2);
End.