Cod sursa(job #522963)
Utilizator | Salajan Razvan vendetta | Data | 16 ianuarie 2011 19:21:45 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.55 kb |
const f='ciur.in';g='ciur.out';
nmax=2000001;
var
v:array[1..nmax] of char;
n,i,j,cate:longint;
begin
assign(input,f);reset(input);
assign(output,g);rewrite(output);
read(n);
//for i:=2 to n do v[i]:='1';
for i:=2 to n do
if v[i]='0' then
begin
inc(cate);
j:=i+i;
while j<=n do
begin
v[j]:='1';
j:=j+i;
end;
end;
write(cate);
close(input);close(output);
end.