Cod sursa(job #362785)

Utilizator arnold23Arnold Tempfli arnold23 Data 10 noiembrie 2009 22:52:34
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.47 kb
const vek:array[1..10] of longint = (5, 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;
 while i<p do begin
   n:=n+5;
   j:=1;
   while (vek[j]<=n) and (i<p) and (j<=10) do begin
     i:=n div vek[j];
     inc(j);
   end;
 end;

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