SQL>
SQL> create or replace function factorial (i NUMBER)
2 return NUMBER
3 is
4 begin
5 if i = 1
6 then
7 return 1;
8 else
9 return i*factorial(i-1);
10 end if;
11 end;
12 /
Function created.