Cod sursa(job #136433)

Utilizator ghitza_2000Stefan Gheorghe ghitza_2000 Data 15 februarie 2008 15:54:12
Problema Factorial Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.58 kb
var n,i,k,ct,h:longint;
   p:array[1..10000] of longint;
   f,g:text;
begin
assign(f,'prim.in'); reset(f);
readln(f,k);
close(f);
i:=2; ct:=1; h:=4; n:=10*k;
while (h<n) do  begin
p[h]:=1;  h:=h+i;
end;
i:=3;
while ct<=k do begin
h:=i;
if p[i]=0 then begin inc(ct);
                      h:=h+2*i;
                      while h<=n do begin
                      p[h]:=1;
                      h:=h+2*i;
                      end;
                 end;
i:=i+2;
end;
assign(g,'prim.out'); rewrite(g);
if k>1 then
write(g,(i-2)*(i-2))
else write(g,'9');
close(g);
end.