# Find the factorial of a number in pl/sql using C++.

C++Server Side ProgrammingProgramming

In this section, we will see how to find factorial of a number using the PL/SQL. In PL/SQL code, some group of commands is arranged within a block of the related declaration of statements.

Factorial of a number is basically multiplication of all integers from 1 to n, where n is the given number. So n! = n * (n – 1) * (n – 2) * … * 2 * 1.

## Example (PL/SQL)

Live Demo

DECLARE
fact number :=1;
n number := &1;
BEGIN
while n > 0 loop
fact:=n*fact;
n:=n-1;
end loop;
dbms_output.put_line(fact);
END;

## Output

Consider 5 has given
120
Published on 30-Oct-2019 10:59:26