https://github.com/afa-farkhod/fibonacci-number
Following analyze and designs an efficient algorithm for finding Fibonacci numbers using dynamic programming.
https://github.com/afa-farkhod/fibonacci-number
algorithms fibonacci-numbers java
Last synced: 2 months ago
JSON representation
Following analyze and designs an efficient algorithm for finding Fibonacci numbers using dynamic programming.
- Host: GitHub
- URL: https://github.com/afa-farkhod/fibonacci-number
- Owner: afa-farkhod
- License: apache-2.0
- Created: 2023-04-13T02:26:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-01T09:21:08.000Z (almost 2 years ago)
- Last Synced: 2025-02-02T01:13:33.946Z (4 months ago)
- Topics: algorithms, fibonacci-numbers, java
- Language: Java
- Homepage: https://en.wikipedia.org/wiki/Fibonacci_sequence
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Fibonacci-Number](https://en.wikipedia.org/wiki/Fibonacci_sequence)
Following analyzes and designs an efficient algorithm for finding Fibonacci numbers using dynamic programming.- In mathematics, the Fibonacci sequence is a sequence in which each number is the sum of the two preceding ones. Numbers that are part of the Fibonacci sequence are known as Fibonacci numbers, commonly denoted Fn. The sequence commonly starts from 0 and 1, although some authors start the sequence from 1 and 1 or sometimes (as did Fibonacci) from 1 and 2. Starting from 0 and 1, the first few values in the sequence are:
```
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
```
- Following images shows the tailing with squares whose side lengths are successive Fibonacci numbers(1, 1, 2, 3, 5, 8, 13, 21)
![]()
- Variables f0, f1 and f2 store three consecutive Fibonacci numbers in the series:
![]()
- The Fibonacci sequence first appears in the book Liber Abaci (The Book of Calculation, 1202) by Fibonacci, where it is used to calculate the growth of rabbit populations. Fibonacci considers the growth of an idealized (biologically unrealistic) rabbit population, assuming that: a newly born breeding pair of rabbits are put in a field. Each breeding pair mates at the age of one month, and at the end of their second month they always produce another pair of rabbits. And rabbits never die, but continue breeding forever.
![]()
- The algorithm for computing Fibonacci numbers presented here uses an approach known as dynamic programming. Dynamic programming is the process of solving subproblems, then combining the solutions of the subproblems to obtain an overall solution. This naturally leads to a recursive solution. However, it would be inefficient to use recursion, because the subproblems overlap. The key idea behind dynamic programming is to solve each subproblem only once and store the results for subproblems for later use to avoid redundant computing of the subproblems.
- Given java program implements the Fibonacci algorithm and runs the demo as following:
![]()