Pagini recente » Cod sursa (job #741089) | Cod sursa (job #849838) | Cod sursa (job #2280860) | Cod sursa (job #2153143) | Cod sursa (job #125937)
Cod sursa(job #125937)
var f,g:text;
ok:boolean;
a,b,c,x,y,p:longint;
begin
assign(f,'factorial.in'); reset(f);
assign(g,'factorial.out'); rewrite(g);
readln(f,p);
a:=0; ok:=false;
b:=maxlongint;
if p=0 then c:=-1
else
while not ok do
begin
y:=5;
c:=(a+b)div 2;
while c div y = 0 do
begin
x:=x+c div y;
y:=y*5;
end;
if x<p then b:=c
else a:=c;
if x=p then ok:=true;
end;
writeln(g,c);
close(g);
end.