C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

Optimization of Fibonacci Calculation Algorithm

Open overinvest opened this issue 10 months ago • 1 comments

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

  • [x] 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
  • [x] PR title follows semantic commit guidelines
  • [ ] Search previous suggestions before making a new one, as yours may be a duplicate.
  • [x] 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.

overinvest avatar Apr 18 '24 21:04 overinvest

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] avatar May 19 '24 00:05 github-actions[bot]

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!

github-actions[bot] avatar May 26 '24 00:05 github-actions[bot]