SIGN UP MEMBER LOGIN:
   
ARTICLE

Program for Finding Factorial of a Number in Pl/Sql

Posted by Navratna Tripathi Articles | PL/SQL March 21, 2013
In this article, we will see the program for finding Factorial a number in Pl/Sql.
Reader Level:

In this article, we will see the program for finding Factorial a number in Pl/Sql.

For finding the factorial of a number, we have to multiply by all the number including the number till 1 as finding the factorial of 5!=5*4*3*2*1=120.

For this we take a number type variable n and store the number at run time in this variable. We take three more variable one for looping that is i, one is storing the factorial value that is f and last one c that is used for just taking the temporary holding the decrement number and multiplied by f variable.

Let play with code.

Example 

declare

       n number(4);

       f number(4):=1;

       c number(4);

       i number(4);

      

begin

      

       n:=&n;

       c:=n;

       for i in 1..n loop

              f:=f*c;

              c:=c-1;

       end loop;

       dbms_output.put_line(f);

             

      

end;

Login to add your contents and source code to this article
This Feature is Sponsored By
post comment
COMMENT USING