Cod sursa(job #6114)

Utilizator Marinescu_DanyelMarinescu George Marinescu_Danyel Data 17 ianuarie 2007 17:43:32
Problema Factorial Scor 15
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.39 kb
Program Factorial;
var f,g:text;
    nrp,x,y,p:integer;
Begin
 assign(f,'fact.in');
 reset(f);
 read(f,p);
If p<>0 then
 begin
 x:=5;
 nrp:=1;
 end
Else
x:=1;
 while nrp<p do
 begin
 x:=x+5;
 y:=x;
 while (y mod 5=0) do
  begin
  nrp:=nrp+1;
  y:=y div 5;
  end;
 end;
If p=5 then
 x:=-1;
 assign(g,'fact.out');
 rewrite(g);
 writeln(g,x);
 close(g);
 close(f);
 End.