PL/SQL Program for Fibonacci Series
Here you will learn pl/sql program for fibonacci series. It is a series, in which each number is the sum of the last two previous numbers.
PL/SQL Program for Fibonacci Series
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | DECLARE n1 NUMBER := 0; n2 NUMBER := 1; nxt_num NUMBER; limit NUMBER := 10; BEGIN -- get user input DBMS_OUTPUT.PUT_LINE('Enter a number: '); limit := &limit; DBMS_OUTPUT.PUT_LINE('Fibonacci Series:'); DBMS_OUTPUT.PUT_LINE(n1); DBMS_OUTPUT.PUT_LINE(n2); FOR i IN 3..limit LOOP nxt_num := n1 + n2; DBMS_OUTPUT.PUT_LINE(nxt_num); n1 := n2; n2 := nxt_num; END LOOP; END; / |
Output
Enter a number: 10
0 1 1 2 3 5 8 13 21 34
Check out our other PL/SQL programs examples