title: Creating plsql function for Factorial program
body: <p>When I call the function using select statement
  [select fact(5) from dual;]
  I get output as 1.Can you guys please help me from the below code</p>
  
  <pre><code>create or replace function fact(num in number)
  
  return number
  
  Is 
  
  res_fact number:=1;
  
  begin
  
  for i in 1..5 loop
  
  res_fact:=res_fact*i;
  
   dbms_output.put_line(res_fact);
  
   -- dbms_output.put_line('Factorial of '||num||' = '||res_fact);
  
   return res_fact;
  
   end loop;
  
   dbms_output.put_line(res_fact);
  
   end;
  
   res_fact=res_fact*i;
   as i call function i used to get the factorial of that input number
   res_fact=5*4*3*2*1;
   res_fact=120
  </code></pre>