Aim:
To find the Fibonacci Series using SQL commands.
Algorithm:
Step 1: Start the program.
Step 2: Declare the values in declare block.
Step 3: Declare the condition in begin block.
Step 4: Get the output using for loop.
Step 5: Stop the process.
Program
DECLARE
first number:=0;
second number:=1;
third number;
n number:=:n;
i number;
BEGIN
dbms_output.put_line(' Fibonacci Series is: ');
dbms_output.put_line(first);
dbms_output.put_line(second);
for i in 2..n
loop
third:=first+second;
first:=second;
second:=third;
dbms_output.put_line(third);
END loop;
END;
OUTPUT:
N | |
Fibonacci Series is:
0
1
1
2
3
5
إرسال تعليق