Cod sursa(job #363035)

Utilizator arnold23Arnold Tempfli arnold23 Data 11 noiembrie 2009 17:04:31
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.47 kb
const vek:array[1..9] of longint = (25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625);

var f:text;
    p,n,i,h,j:longint;

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

 i:=0;
 if p=0 then n:=1 else
 n:=0;
 h:=1;
 j:=1;
 while i<p do begin
   n:=n+5;
   inc(i);
   if (n>=vek[j]) and (j<=9) then begin
   i:=i+n div vek[j];
   inc(j);
   end;
 end;

 assign(f,'fact.out');
 rewrite(f);
 writeln(f,n);
 close(f);
end.