Fibonacci Numbers
Table of Content:
Fibonacci Numbers: A sequence where each number is the sum of the two preceding ones, usually starting with 0 and 1. Example: 0, 1, 1, 2, 3, 5, 8.
The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it:
- the 2 is found by adding the two numbers before it (1+1),
- the 3 is found by adding the two numbers before it (1+2),
- the 5 is (2+3),
- and so on!
It is that simple!
Here is a longer list:
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, ...
Can you figure out the next few numbers?
Makes A Spiral
When we make squares with those widths, we get a nice spiral:
First, the terms are numbered from 0 onwards like this:
| n = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ... |
| xn = | 0 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | 89 | 144 | 233 | 377 | ... |
So term number 6 is called x6 (which equals 8).
|
Example: the 8th term is
|
![]() |
So we can write the rule:
The Rule is xn = xn−1 + xn−2
where:
- xn is term number "n"
- xn−1 is the previous term (n−1)
- xn−2 is the term before that (n−2)
Example: term 9 is calculated like this:
- Assignment 1: Write a program to perform binary search on a list of integers given below to search for an element input by the user. If it is found, display the element along with its position; otherwise, display the message "Search element not found."
5, 7, 9, 11, 15, 20, 30, 45, 89, 97 - Assignment 2: check if a number is a Fibonacci number in Java
- Assignment 3: Check if a Number is a Fibonacci Number in Range using Java
