Problem 44628. The other half of the Fibonacci sequence
The "Fibonacci sequence" — F = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ...] — appeared in Indian mathematical expositions from circa 700 CE or earlier, and in the writings of Leonardo of Pisa (a.k.a. "Fibonacci") circa 1202 CE.
This sequence can be defined by
F(n+2) = F(n+1) + F(n)
in which F(1) = 1, F(2) = 1, F(3) = 2, ....
Later in history, it was recognised that F(0) = 0. Of course, this still satisfies the formula in bold above [for n=0]: F(2) = F(1) + F(0).
Your job in this Cody Problem is to 'create history'(?) by extending this sequence to negative values of n, to discover the missing half of this sequence!
EXAMPLE:
If n=-1, then F(-1) must be 1, to ensure that F(1) = F(0) + F(-1) — thus satisfying the formula in bold above.
You are only required to provide outputs for n < 3 that can be represented by an int64 data type. To enforce this, your output needs to be of this data type.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers17
Suggested Problems
-
Determine if a Given Number is a Triangle Number
377 Solvers
-
Back to basics 8 - Matrix Diagonals
924 Solvers
-
Number of 1s in a binary string
9083 Solvers
-
The Answer to Life, the Universe, and Everything
528 Solvers
-
600 Solvers
More from this Author32
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!