Mysql Fibonacci Series With Stored Procedure

Mysql Fibonacci Series With Stored Procedure
Written by Thomas Brown

What is the Fibonacci series: The first number of this series is 0 and the second number is 1. The other numbers in this series are found by the sum of the two preceding numbers. For example, the 3rd number in the series is 1, which is the sum of 0 and 1. The 4th number in the series is the sum of 1 and 1 is 2. The 5th issue of the series is; It is equal to 3, which is the sum of the number 2, which is the 4th number in the series, and the number 1, which is the 3rd number in the series. The series continues like this.

We will write a procedure that finds this series. The number of the serial number that is desired to be displayed as a parameter will be entered. The procedure will show us as many results as requested.

The code of the procedure is as follows. First we need to run this code. If we ran it without an error message, we can now use our procedure.

When you run the code above you will get succesfull message. After you can run the codes below

Example-1

Result

Example-2

Result

MySql Fibonacci Sequence With Stored Procedure Solution 2

The deference in this solution, I used the query in the aggregation process. In solution 1, I used two integer variable instead.

Example-1

Result

Example-2

Result

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: