Oralce PL/SQL examples of recursion (#91)

This commit is contained in:
Timur Tarasenko
2018-10-18 10:27:58 -05:00
committed by Aditya Bhargava
parent 31412a0b96
commit ac08df2ee7
3 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
SET SERVEROUTPUT ON
DECLARE
result NUMBER;
FUNCTION factorial(x NUMBER)
RETURN NUMBER
IS
f NUMBER;
BEGIN
IF x = 0 THEN
f := 1;
ELSE
f := x * factorial(x - 1);
END IF;
RETURN f;
END;
BEGIN
result := factorial(5);
dbms_output.put_line(result);
END;