Cod sursa(job #696031)
Utilizator | Data | 28 februarie 2012 16:25:55 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 10 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
var f:text;i,n,k,j:longint;a:array[1..2000000]of boolean;
begin
assign(f,'ciur.in');reset(f);
read(f,n);
close(f);
for i:=n downto 2 do
a[i]:=true;
for i:=2 to n do
if a[i]=true then begin
k:=k+1;
j:=i+1;
while j<=n do
begin
a[j]:=false;
j:=j+i;
end;
end;
assign(f,'ciur.out');rewrite(f);
write(f,k);
close(f);
end.