Mai intai trebuie sa te autentifici.
Cod sursa(job #292271)
Utilizator | Data | 30 martie 2009 22:11:55 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | fpc | Status | done |
Runda | The Beginners | Marime | 0.41 kb |
var x,n,k,i:longint; a:array[1..20000000] of byte; f,g:text;
begin
assign(f,'ciur.in'); reset(f);
readln(f,n); close(f);
for i:=1 to n do
a[i]:=1;
a[1]:=0;
for i:=2 to n do
if (a[i]=1) then
begin
x:=2*i;
k:=k+1;
while x<=n do
begin
a[x]:=0;
x:=x+i;
end;
end;
assign(g,'ciur.out'); rewrite(g);
writeln(g,k); close(g);
end.