Cod sursa(job #1997432)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 4 iulie 2017 12:37:47
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.57 kb
Program Factorial;
var i,p:0..100000010;
n,k:longint;
f,g:text;
function IsPow5(k:longint) :boolean;
var i:longint;
begin
 if (k=0) or (k=1) then begin
 IsPow5:=false;
 exit;
 end;
 i:=1;
 while i < k do
  i:=i*5;
if i = k then
 IsPow5:=true
 else
 IsPow5:=false;
end;
begin
assign(f,'fact.in');assign(g,'fact.out');
reset(f);rewrite(g);
readln(f,p);
i:=0;
 if IsPow5(p) then n:=-1 else begin
 if i<p then
  n:=0
  else
  n:=1;
 while i<p do begin
 if IsPow5(i) = false then
  n:=n+5;
  i:=i+1;
 end;
end;
writeln(g,n);
close(f);close(g);
end.