Cod sursa(job #6458)

Utilizator Marinescu_DanyelMarinescu George Marinescu_Danyel Data 19 ianuarie 2007 18:18:01
Problema Factorial Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.43 kb
Program Factorial;
var p,p1,x,n,i:longint;
    f,g:text;
    ok:boolean;
Begin
assign(f,'fact.in');
reset(f);
read(f,p);
close(f);
If p=0 then
 n:=1
Else
 begin
 n:=4*p+1;
 ok:=false;
 Repeat
 x:=5;
 p1:=0;
 Repeat
 p1:=p1+trunc(n/x);
 x:=x*5;
 Until x>n;
 If p1>=p then
 ok:=true
 Else
 n:=n+1;
 Until ok;
If p1<>p then
n:=-1;
 End;
assign(g,'fact.out');
rewrite(g);
write(g,n);
close(g);
End.