Java icon indicating copy to clipboard operation
Java copied to clipboard

fix: handle zero case in Armstrong number check to avoid Math.log10(0…

Open Tejaswi1305 opened this issue 6 months ago • 2 comments

Adds a safe check for number == 0 in the Armstrong number logic to avoid a Math.log10(0) exception. Also acknowledges 0 as a valid Armstrong number (since 0^1 = 0).

Why: Without this, passing 0 causes an ArithmeticException due to log10(0). This PR ensures the code handles all valid inputs correctly.

Tejaswi1305 avatar Apr 29 '25 14:04 Tejaswi1305

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 73.80%. Comparing base (d866fbd) to head (c8b9d60).

Files with missing lines Patch % Lines
...c/main/java/com/thealgorithms/maths/Armstrong.java 83.33% 1 Missing and 1 partial :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6229      +/-   ##
============================================
- Coverage     73.80%   73.80%   -0.01%     
  Complexity     5311     5311              
============================================
  Files           673      673              
  Lines         18376    18378       +2     
  Branches       3553     3554       +1     
============================================
+ Hits          13563    13564       +1     
  Misses         4265     4265              
- Partials        548      549       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Apr 29 '25 14:04 codecov-commenter

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

github-actions[bot] avatar May 30 '25 00:05 github-actions[bot]

Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution!

github-actions[bot] avatar Jun 06 '25 00:06 github-actions[bot]