Cod sursa(job #1581423)

Utilizator DoubleNyNinicu Cristian DoubleNy Data 26 ianuarie 2016 20:01:06
Problema Factorial Scor 5
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.72 kb
Program infoarenafact;
   var p,n,pow,i:longint;
       fin,fou:text;
begin
assign(fin,'fact.in');
reset(fin);
assign(fou,'fact.out');
rewrite(fou);


n:=25;
pow:=1;
readln(fin,p);
if p<=4 then n:=p*5
else if (p+1) mod 6=0 then n:=-1
else if p=0 then n:=1
else

 while p>6 do
  begin
   p:=p div 5;
   inc(pow);
  end;
for i:=1 to pow-1 do n:=n*5;
write(fou,n);
readln;
close(fin);
close(fou);

{ assign(fin,'fact.in');
 reset(fin);
 readln(fin,p);
 close(fin);
 if (p+1) mod 6=0 then n:=-1
 else
 if p=0 then n:=1
 else
 if p<=4 then
  begin
    n:=p*5;
  end
      else if p>5 then n:=(p*5)-5; }
{ assign(fou,'fact.out');
 rewrite(fou);
 write(fou,n);
 close(fou);
 readln;   }
end.