PL/SQL Procedure to Find Factorial of Given Number

PL/SQL Procedure to Find Factorial of Given Number:



create or replace procedure fact1(no in number) is
fact number;
invalid_no exception;
begin
if(no=0) then
raise invalid_no;
else
fact:=1;
for i in 1..no
loop
fact:=fact*i;
end loop;
end if;
dbms_output.put_line('Factorial='||fact);
exception
when invalid_no then
dbms_output.put_line('Please enter number greater than zero');
end;

Calling Procedure:

begin
fact1(0);
end;

 

Leave a Reply

Your email address will not be published. Required fields are marked *

14 + 1 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.