Cod sursa(job #247295)
| Utilizator | Data | 22 ianuarie 2009 19:08:30 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
// Arhiva educationala - ciurul lui Eratosthens
var n,i,k,count : longint;
f : text;
v : array [1..2000000] of byte;
begin
assign (f,'ciur.in');
reset (f);
readln (f, n);
close (f);
fillchar(v, sizeof(v), 1);
count:= 0;
for i:= 2 to n do
if (v[i] = 1) then
begin
inc(count);
for k := 2 to n div i do
v[i*k] := 0;
end;
assign (f,'ciur.out');
rewrite (f);
writeln (f, count);
close (f);
end.