Cod sursa(job #1088054)
| Utilizator | Data | 20 ianuarie 2014 09:23:14 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
type Tab=array[1..2000000] of longint;
var f,g:text; a:tab; n,i,j,k:longint;
begin
assign(f, 'ciur.in');
reset(f);
assign(g, 'ciur.out');
rewrite(g);
k:=0;
readln(f, n);
for i:=2 to n do a[i]:=1;
for i:=2 to n do
if a[i]=1 then begin
j:=i*2;
while j<=n do
begin
if a[j]=1 then a[j]:=0;
j:=j+i;
end;
end;
for i:=2 to n do
if a[i]=1 then inc(k);
write(g, k);
close(f); close(g);
end.
