Cod sursa(job #22115)

Utilizator TudorutzuMusoiu Tudor Tudorutzu Data 25 februarie 2007 18:00:34
Problema Factorial Scor 15
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.49 kb
var f,g:text;
    p,x,y,z,i,m:longint;
begin
     assign(f,'fact.in'); reset(f);
     assign(g,'fact.out'); rewrite(g);
     read(f,p);  x:=0;
     if p<0 then x:=0;
     if p=0 then x:=1;
     if p>0 then
     begin
          x:=p;
          for i:=1 to p*5-1 do
          if (i div 5 mod 5=0) and (i div 5<>0)
              and (i mod 5=0) then
                      dec(x);
          x:=x*5;
     end;
     if x=0 then write(g,'-1')
            else write(g,x);
     close(g);
end.