Fibonacci sequence

In the Fibonacci sequence each term is the sum of the previous two. The first two terms are 1, 1.

1, 1, 2, 3, 5, 8, 13, 21,…

Recursive definition

This function allows us to define the nth term of the Fibonacci sequence recursively, that is, starting from the previous value. The function is called cascading until it finds an initial value.

Curiosity

One of the most interesting peculiarities of this sequence is that it has many references in Nature. It Is the succession of perfection and symmetry. The ratio of its adjacent numbers tends to $\Phi = 1,618...$ also called the Golden Section.

If we imagine the numbers as areas of a square and we have the squares close together in order to complete a rectangle, we discover not only that this is always possible, but since inside each square it is possible to draw with the compass a semicircle that goes from A vertex to the opposite, joining the drawings comes out the figure of a spiral.

Credits Image: Wikipedia

Now you try

Choose the 1 < nth < 3*101 number of Fibonacci sequence.t

<?php
function fibonacci(\$n) {
if (\$n < 0) return false;
if (\$n < 2) return 1;

return fibonacci(\$n - 1) + fibonacci(\$n - 2);
}

\$IN = (array) json_decode(base64_decode(\$argv));
extract(\$IN);
echo fibonacci(\$n);
?>

{
"N": 6
}
13