TheAlgorithms / C-Plus-Plus

Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
https://thealgorithms.github.io/C-Plus-Plus
MIT License
30.03k stars 7.1k forks source link

Fix, Docs, Test: Fibonacci_fast (Renamed to Fibonacci_iterative) #2614

Closed Renjian-buchai closed 4 months ago

Renjian-buchai commented 11 months ago

Description of Change

The original algorithm does not calculate the nth fibonacci number, but rather the next fibonacci number after storing it in a static variable. Thus, I abstracted the looping part out of the code that you have to write upon application, into the function itself.

The "Test" in main does not really test anything, rather demonstrates what it does. Added actual unit tests with test cases.

The "Test" in main also does not calculate the nth fibonacci number, but rather the (n+1)th fibonacci number.

The maximum value that can be computed such that the result is less than UINT64_MAX is also incorrect because of the above error.

The file brief did not explain what it actually does properly.

Checklist

Notes: Fixed bugs, added documentation, and unit tests for Fibonacci_fast (Renamed to Fibonacci_iterative to better reflect what it actually does).

For #2456.

Renjian-buchai commented 11 months ago

I genuinely don't know what the original author was trying to do here, tbh.

github-actions[bot] commented 9 months ago

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 9 months ago

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

realstealthninja commented 5 months ago

@Panquesito7 could we get this merged?