Skip to content

Optimized the code of armstrong_number.cpp - #3186

Closed
TechWhiz42 wants to merge 1 commit into
TheAlgorithms:masterfrom
TechWhiz42:optimized_armstrong_number.cpp
Closed

Optimized the code of armstrong_number.cpp#3186
TechWhiz42 wants to merge 1 commit into
TheAlgorithms:masterfrom
TechWhiz42:optimized_armstrong_number.cpp

Conversation

@TechWhiz42

@TechWhiz42 TechWhiz42 commented Jun 30, 2026

Copy link
Copy Markdown

Description of Change

  • Fixed the edge case where 0 was treated as having 0 digits by correctly considering it a one-digit number.
  • Replaced floating-point exponentiation (std::pow) with an integer exponentiation helper function to avoid unnecessary floating-point operations.
  • Added additional self-test cases to improve test coverage for valid and invalid Armstrong numbers.
  • Removed the unused <cmath> header after eliminating std::pow().

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
  • 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: Improves correctness for the edge case of 0, replaces floating-point exponentiation with integer arithmetic, and expands the self-test suite.

@TechWhiz42

TechWhiz42 commented Jun 30, 2026

Copy link
Copy Markdown
Author

Hey people,
This is my very first contribution. Even if my contribution is not merged, please tell me how can I improve. That will be more than enough.
Thank you.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
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 Aug 9, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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 github-actions Bot closed this Aug 17, 2026
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.

1 participant