AddThis Social Bookmark Button

Calculate Factorial of a number like 4!=4*3*2*1

Declare

num   number:= #

fact number:= 1;

temp number;

begin

  temp := num;

   while (num > 0)
loop
    fact := fact * num;

    num   := num - 1;

 end loop;

  Dbms_Output.Put_line('factorial of ' || num ||

                       '  is ' || fact);
end;