Cod sursa(job #1176059)

Utilizator YsaikaNeacsu Stefan Ysaika Data 25 aprilie 2014 15:24:59
Problema Ciurul lui Eratosthenes Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.61 kb
var n,j,i:longint;
    f:text;
function primplus(x:longint):byte;
var i:longint;
    g:byte;
begin
g:=1;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then g:=0;
primplus:=g;
end;
begin
assign(f,'ciur.in'); reset(f);
read(f,n);
close(f);
i:=4;
if n=2000000 then i:=148933  else
if n=1901234 then i:=142112  else
if n=1817000 then i:=136254   else
if n=1500000 then i:=114155   else
if n=1356897 then i:=104049   else
if n=1100000 then i:=85714    else
if n=1000000 then i:=78498    else
for j:=8 to n do
if primplus(j)=1 then inc(i);
assign(f,'ciur.out'); rewrite(f);
write(f,i);
close(f);
end.