Cod sursa(job #54514)

Utilizator h_istvanHevele Istvan h_istvan Data 24 aprilie 2007 22:12:57
Problema Factorial Scor 15
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.55 kb
program fact;
var f:text;
    p,h,s,d,i,e:longint;
    a:extended;

begin
     assign(f,'fact.in');
     reset(f);
     readln(f,p);
     close(f);

     h:=5;
     while(h < p) do h:=h*5;
     s:=h;

     h:=5;
     while(h <= s) do
     begin
          d:=d+(s div h);
          h:=h*5;
     end;

     a:=(p/d)*s;

     assign(f,'fact.out');
     rewrite(f);
     if(p>0) then
     begin
          e:=trunc(a);
          while (e mod 5 <> 0) do e:=e+1;
          writeln(f,e);
     end else writeln(f,1);
     close(f);
end.