Subscribe:Posts Comments

You Are Here: Home Pascal Tình giai thừa trong Pascal (n!)



program tinhgiaithu;
 uses crt;
  var n,i: integer;
        gt: longint;
begin
  write('Giai thua cua n='); readln(n);
    gt:=1;
  if N<0 then writeln(#7,'Khong duoc vi N<0')
    else
   begin
      if N>0 then
     for i:=1 to N do gt:=gt*i;
    writeln(N,'!=',gt);
   end;
  readln
end.
Tags: Pascal

0 nhận xét

Leave a Reply