Skip to content

Fibonacci sequence should start with [0, 1] and not [1, 1] #708

Closed
@cchexcode

Description

@cchexcode

Summary

The Fibonacci sequence is defined by following statement:
F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. For reference, please see The online encyclopedia of integer sequences as primary reference, leading to other references with more detailed description.
(Older) books sometimes omit the preceding 0, but this representation is deprecated.

Current status

fibMemo

When calling the function Fibonacci.fibMemo, the result of F(0) = 1. This is incorrect since F(0) = 0. Furthermore this leads to the following sequence for the first few integers: [1, 1, 1, 2, 3, 5, ...] for input=[0, 1, 2, 3, 4, 5, ...].

fibBotUp

When calling the function Fibonacci.fibBotUp, the program throws an exception when trying to get the value for F(0) from the map. Therefore F(0) is not supported by this implementation.

Task

Fix both implementation(s) to
a) Return correct values for F(x)
b) Do not throw exceptions
Acceptance criteria is met when both functions return [0, 1, 1, 2, 3, 5] for input=[0, 1, 2, 3, 4, 5].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions