Cod sursa(job #273821)

Utilizator DarkByteVictor Pop DarkByte Data 9 martie 2009 01:42:27
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.5 kb
var P, value : longint;
    f : textfile;

begin
  Assign(f, 'fact.in');
  Reset(f);
  Read(f, P);
  Close(f);

  value := 0;
  case P of
    -1 : value := -1;
    0  : value := 1;
    else
      begin
        if (P div 5 = 0) then
          begin
            value := -1;
          end;
        if value <> - 1 then
          if P >= 10
            then dec(P);
          value := 5 * P;
      end;
  end;

  Assign(f, 'fact.out');
  Rewrite(f);
  Write(f, value);
  Close(f);
end.