Cod sursa(job #1980746)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 13 mai 2017 22:00:24
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.43 kb
Program Ciur;
var A:array[1..2000000] of boolean;
n,i,j,s,v,p:0..2000000;
f,g: text;
begin
assign(f,'ciur.in');
assign(g,'ciur.out');
reset(f);
rewrite(g); 
readln(f,n);
for i:=1 to n do
 A[i]:= true;
i:= 2;
while i<=n do begin
//p:=i*i;
if A[i] = true then begin
 j:=1;
 while i*j <= n do begin
  A[i*j]:= false;
  j:= j + 1;
  end;
 s:=s+1;
 end;
i:= i+1;
end;
writeln(g,s);
readln;
close(f);
close(g);
end.