The Wayback Machine - https://web.archive.org/web/20201103193247/https://github.com/TheAlgorithms/Java/issues/708
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
replicadse opened this issue Feb 20, 2019 · 3 comments
Closed

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

replicadse opened this issue Feb 20, 2019 · 3 comments

Comments

@replicadse
Copy link
Contributor

@replicadse replicadse commented Feb 20, 2019

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].

@ales-blaze
Copy link

@ales-blaze ales-blaze commented Feb 20, 2019

i will work on it!

@replicadse
Copy link
Contributor Author

@replicadse replicadse commented Feb 26, 2019

@ales-blaze I have already fixed the bug because I was really bored. See the attached PR.

Furthermore: This bugfix was not intended to include major restructures but I highly suggest restructuring this repo and updating the code in order to keep up some quality in an additional issue.
There are some poor implementations and, as this bug showed, there are no tests that validate the correctness of proposed work. The only validation mechanisms is console output which is kind of pre 2000...

@yanglbme yanglbme closed this in dda712c Feb 27, 2019
@wangyuan2019
Copy link

@wangyuan2019 wangyuan2019 commented Apr 4, 2019

I will try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.