Cod sursa(job #1928)

Utilizator radu91cristache radu radu91 Data 15 decembrie 2006 14:11:40
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.41 kb
program factorial;
var f1,f2:text; p,n,x,c,y:longint;
begin
assign(f1,'fact.in');
reset(f1);
read(f1,p);
close(f1);
n:=0;
x:=0;
c:=0;
repeat
x:=x+1;
y:=x;
if (y mod 5=0) then
   case y of
   5: c:=c+1;
   25: c:=c+2;
   125: c:=c+3;
   625: c:=c+4;
   3125: c:=c+5
   end;
n:=n+1
until (c=p) or (c>p);
if c>p then
n:=-1;
assign(f2,'fact.out');
rewrite(f2);
writeln(f2,n);
close(f2);
end.