Cod sursa(job #282768)

Utilizator andreirulzzzUPB-Hulea-Ionescu-Roman andreirulzzz Data 18 martie 2009 10:49:43
Problema Factorial Scor 25
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.58 kb
program factorial;
const v:array[1..17] of int64=(5,25,125,625,3125,15625,78125,390625,
1953125,9765625,48828125,244140625,1220703125,6103515625,30517578125,
152587890625,762939543125);
var n,p,aux,zero:int64;
begin
assign(input,'fact.in');
reset(input);
read(input,p);
close(input);
n:=0; zero:=0;
if p>2430000 then n:=9720020;
repeat
      n:=n+5;
      aux:=2;
      while n mod v[aux]=0 do inc(aux);
      zero:=zero+aux-1;
until zero>=p;
if p=0 then n:=1;
if zero>p then n:=-1;
assign(output,'fact.out');
rewrite(output);
write(output,n);
close(output);
end.