Cod sursa(job #869854)
| Utilizator | Data | 2 februarie 2013 14:12:07 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
Program eratosthenes;
var a:array[2..2000000] of boolean;j,n,x:longint;i:integer;
f,g:text;
Begin
assign(f,'ciur.in');reset(f);
assign(g,'ciur.out');rewrite(g);
readln(f,n);
close(f);
For i:=2 to trunc(sqrt(n)) do
If a[i]=false then
Begin
j:=2;
repeat
a[j*i]:=true;
j:=j+1;
until j*i>n;
end;
x:=0;
For j:=2 to n do
If a[j]=false then
x:=x+1;
writeln(g,x);
close(g);
end.
