Preview:
create or replace FUNCTION  factorial(num in integer) return integer
Is 
i integer;
res integer:=1;
BEGIN
  for i in 1 .. num
   loop
    res:=res*i;
   end loop;
  return res;
end;
/
declare 
 a integer:=&a;
begin
  dbms_output.put_line('factorial :'||factorial(a));
end;
/
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter