How to print Fibonacci Series by PL/SQL

Fibonacci Series

----------------------------------------------------------------

* The Fibonacci numbers are the numbers in the following integer 

Sequence: 0 1 1 2 3 5 8 13 21

* The first two numbers in the fibonacci sequence are 0 and 1. and each subsequence nubmer

 is the sum  of the previous two.

-----------------------Start Codes----------------------------

set serveroutput on;

declare

first_no number := 0;

second_no number := 1;

series_lng number := 50;

febo_sum number := 0;

counter number := 1;

begin

dbms_output.put(first_no);

dbms_output.put(','||second_no);

series_lng := series_lng-2;

while (counter <= series_lng) loop

 febo_sum := first_no + second_no;

 dbms_output.put(','||febo_sum);

 first_no  := second_no;

 second_no := febo_sum;

 counter := counter + 1;

end loop;

dbms_output.new_line;

end;

Result: 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049



Comments

Popular posts from this blog

How to create and show html report by ajax callback and print report in Oracle Apex

How to insert and show blob images in form and report of Oracle Apex

CRUD Operation from HTML