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!


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

20.99% Correct | 79.01% Incorrect
Last Solution submitted on Mar 04, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers16

Suggested Problems

More from this Author32

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!