Cod sursa(job #5409)
| Utilizator | Data | 12 ianuarie 2007 12:49:20 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 1.02 kb |
program fact;
var f,g:text;
p:longint;
procedure iofile;
begin
assign(f,'fact.in');
reset(f);
assign(g,'fact.out');
rewrite(g);
readln(f,p);
if p=0 then
begin
writeln(g,'1');
close(g);
halt;
end;
close(f);
end;
procedure prel;
var x,diviz,i:longint;
begin
x:=1;
diviz:=1;
while x<=p do
begin
diviz:=diviz*5;
x:=x*5+1;
end;
x:=(x-1)div 5;
diviz:=diviz div 5;
i:=0;
while p>0 do
begin
i:=i+(p div x)*diviz;
p:=p mod x;
x:=(x-1)div 5;
diviz:=diviz div 5;
end;
writeln(g,i*5);
close(g);
end;
begin
iofile;
prel;
end.