# Fibonacci Sequence

A Fibonacci sequence is a series of numbers in which each number (Fibonacci number) is the sum of the two preceding numbers.

## Simple Fibonacci sequence

### Generating the sequence:

Let's examine the simpliest Fibonacci series and how the sequence is generated.

First number = 0

Second number = 1

Add the two numbers 0 + 1 (to get the third number) = 1

We now have:

First number = 0

Second number = 1

Third number = 1

Then add the next two numbers (number two and number 3) 1 + 1 (to get the fourth number) = 2

We now have:

First number = 0

Second number = 1

Third number = 1

Fourth number = 2

Then add the next two numbers (number 3 and number 4) 1 + 2 (to get the fifth number) = 3

We now have:

First number = 0

Second number = 1

Third number = 1

Fourth number = 2

Fifth number = 3

Then add the next two numbers (number 4 and number 5) 2 + 3 (to get the sixth number) = 5

We now have:

First number = 0

Second number = 1

Third number = 1

Fourth number = 2

Fifth number = 3

Sixth number = 5

The process can be repeated for the number of elements desired.

Here is the first ten elements in Fibonacci's sequence:

First number = 0

Second number = 1

Third number = 1

Fourth number = 2

Fifth number = 3

Sixth number = 5

Seventh number = 8

Eight number = 13

Ninth number = 21

Tenth number = 34

Crazy how they are getting larger!

Wonder what a graph of the sequence would look like?

## More extension questions!

What are the next 10 numers?

How many numbers will it take before the sequence reashers or passes 1 000?

10 000?

100 000?

1 000 000?

If the number of numbers it takes to reach a higher number decreases, then will the number sequence end?

That's all ...

• More fun with Fibonacci ... see print out of computer generated first 12 numbers.
• Program in PHP that generated it.
• See Fibonacci Numbers in Nature

Enjoy!

## PHP program to generate a Fibonacci sequence

<?php
//PHP code to calculate Fibonacci sequence;
\$num = 0;
\$n1 = 0;
\$n2 = 1;
echo "<h2>Fibonnacci Sequence " . \$x . "<h2>";
echo "<br>";
echo \$y;
echo "<h3>Fibonacci series for the first 12 numbers!<h3>";
echo "\n";
echo \$n1 . " " . \$n2 . " ";
while (\$num<10){
\$n3=\$n2+\$n1;
echo(\$n3.' ');
\$n1=\$n2;
\$n2=\$n3;
\$num=\$num+1;
}
?>

Link to an html page with this program.

Top