PL/SQL Program for Fibonacci Series


Fibonacci Series is a series of numbers in which each number is the sum of the two preceding numbers. The simplest example of Fibonacci Series is the series 1, 1, 2, 3, 5, 8, etc.


PL/SQL Program for Fibonacci Series

declare
  num1 number:=0;
  num2 number:=1;
  num3 number;
  n number:=7;
  k number;
 
begin
  dbms_output.put_line('Fibonacci series is:');
  dbms_output.put_line(num1);
  dbms_output.put_line(num2);	
 
  for k in 2..n
  loop
    num3:=num1+num2;
    num1:=num2;
    num2:=num3;
    dbms_output.put_line(num3);
  end loop;
end;

Output:-

Fibonacci series is:
0
1
1
2
3
5
8
13
https://bit.ly/2lgLuJ1 https://bit.ly/2lAbgYW https://bit.ly/2ngU8ry

Leave a Reply

Your email address will not be published. Required fields are marked *