Cod sursa(job #51657)
| Utilizator | Data | 16 aprilie 2007 09:43:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
program untitled;
var sol:record
x5,x2:integer;
end;
n,i:longint;
procedure get_x2_x5(i:integer;var x,y:integer);
begin
while i mod 2 = 0 do
begin
inc(y);
i:=i shl 2;
end;
while i mod 5 = 0 do
begin
inc(x);
i:=i div 5;
end;
end;
begin
assign(input,'fact.in');
reset(input);
assign(output,'fact.out');
rewrite(output);
readln(n);
i:=0;
while (sol.x5<>n) and (sol.x2<>n) do
begin
inc(i);
get_x2_x5(i,sol.x5,sol.x2);
end;
if n>0 then writeln(i);
close(output);
end.