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

Optimization of Fibonacci Calculation Algorithm #2691

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

overinvest
Copy link

Description of Change

  • Using a vector to store Fibonacci numbers: Instead of using two strings fibMinus1 and fibMinus2 to store the last two Fibonacci numbers, we used a vector. This made it possible to simplify the code and make it more readable.

  • Optimization of the addition function: Instead of adding zeros to a shorter string, we just took this into account in the addition cycle, checking if the index is out of line.

  • Using std::string::push_back and std::string::insert: Instead of concatenating strings, we used push_back and insert to add characters and strings. It's more efficient in terms of performance.

  • Using std::to_string to convert numbers to strings: Instead of complex conversion of numbers to strings using ASCII codes, we used std::to_string.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Optimized the Fibonacci calculation algorithm for better performance and readability.

Improvements and optimization
Copy link
Contributor

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 github-actions bot added the stale Author has not responded to the comments for over 2 weeks label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Author has not responded to the comments for over 2 weeks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant