PL/SQL block to obtain factorial of a number
Q. Write a Pl/SQL block to obtain factorial of a number.
The factorial of a non-negative integer 'n' is denoted by n!. It is the product of all positive integers less then or equal to 'n'.
3! = 3*2*1 = 6
num number:= #
fact number:= 1;
temp := num;
while (num > 0)
fact := fact * num;
num := num - 1;
Dbms_Output.Put_line('factorial of ' || temp || ' is ' || fact);
The above program will compute the factorial of a given number.