Quantcast
Channel: The Crazy Programmer
Viewing all articles
Browse latest Browse all 761

PL/SQL Program to Find Factorial of a Number

$
0
0

Here you will get pl/sql program to find factorial of a number.

We can calculate factorial of a number by multiplying it with all the numbers below it.

For example factorial of 5 = 5 x 4 x 3 x 2 x 1 = 120.

 

PL/SQL Program to Find Factorial of a Number

declare
	n integer;
	fac integer:=1;
	i integer;

begin
	n:=&n;

	for i in 1..n
	loop
		fac:=fac*i;
	end loop;

	dbms_output.put_line('factorial='||fac);
end;

 

 

Output

Enter value for n: 10
old 7: n:=&n;
new 7: n:=10;
factorial=3628800

The post PL/SQL Program to Find Factorial of a Number appeared first on The Crazy Programmer.


Viewing all articles
Browse latest Browse all 761

Trending Articles