Cod sursa(job #1507219)
Utilizator | Data | 21 octombrie 2015 15:52:42 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
var k,n,i,j:longint;
ciur:array[2..2000003]of boolean;
f:text;
begin
assign(f,'ciur.in');
reset(f);
readln(f,n);
close(f);k:=0;
for i:=2 to n do
if not ciur[i] then
begin
inc(k);
j:=i*i;
while (j<=n)and(j>0) do
begin
ciur[j]:=true;
inc(j,i)
end;
end;
assign(f,'ciur.out');
rewrite(f);
writeln(f,k);
close(f);
end.