Cod sursa(job #1244546)

Utilizator xxandru1998Guzun Alexandru xxandru1998 Data 17 octombrie 2014 18:53:02
Problema Factorial Scor 5
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.31 kb
Program fact;
 var fi,fo:text;
    i,n,p:longint;
begin
assign(fi,'fact.in'); reset(fi);
assign(fo,'fact.out'); rewrite(fo);
n:=1;
readln(fi,p);
if p<0 then writeln(fo,'-1')
       else if p=0 then writeln(fo,'1')
                   else for i:=1 to p do n:=n*i; writeln(fo,n);

close(fi);
close(fo);
end.