Cod sursa(job #1192811)

Utilizator valen.valentinValentin Valeanu valen.valentin Data 29 mai 2014 19:56:42
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.37 kb
program ciur;
type
tabel=array [0..2000005] of boolean;
var
a:tabel;
n,x,i,j:longint;
f1,f2:text;
begin
assign (f1,'ciur.in');
assign (f2,'ciur.out');
reset (f1);
rewrite (f2);
readln (f1,n);
for i:=2 to n do
if not a[i] then for j:=2 to n div i do a[i*j]:=true;
a[1]:=true;
for i:=2 to n do
if not a[i] then x:=x+1;
writeln (f2,x);
close (f1);
close (f2);
end.