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 number; fac number:=1; i number; 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
Hi,
My name is Shiva. I have been lately working in PL/SQL. I have few doubts that I wanna clarify. How to use multiple procedures in same file(.sql format). I get error every time I execute it. But when I copy the same procedure separately in different file, it works. Could you give some examples of the same?
i cant understand what are you saying???plzz give more information about this content.
What is programming uses
sir please upload the pl/sql program for multiple of any number with function and procedure ….
error in your code do it correct n=&n has mistake please correct and update it
oracle 10g use n:=:n;
Thank you 🙏🏻👍
At the end of the file, you can use / to separate your procedures.
code not working change it
Sir plz upload PL/SQL program to find largest of 2 numbers using if statement
What happened fac number=2;
Declare
Var a := 12;
Var b := 10;
Begin
If a > b then
Dbms_output.put_line(‘ a is greater !’)
Elsif a= b then
Dbms_output.put_line(‘ Both are equal !’)
Else
Dbms_output.put_line(‘ b is greater !’)
End if;
End;
just believe in god and the progran then u can easily perform the program with out any errors others wise u have another solution that is turn east and bend…
I tried it many time but it isn’t show Ans(fraction) PLEASE HELP
declare
2 n number;
3 fac number:=1;
4 i number;
5
6 begin
7 n:=&n;
8 for i in 1..n
9 loop
10 fac:=fac*i;
11 end loop;
12 dbms_output.put_line(‘factorial=’||fac);
13 end;
14 /
Enter value for n: 5
old 7: n:=&n;
new 7: n:=5;
PL/SQL procedure successfully completed.