Add Armstrong Number algorithm with comprehensive tests#7095
Closed
duvvuvenkataramana wants to merge 2 commits intoTheAlgorithms:masterfrom
Closed
Add Armstrong Number algorithm with comprehensive tests#7095duvvuvenkataramana wants to merge 2 commits intoTheAlgorithms:masterfrom
duvvuvenkataramana wants to merge 2 commits intoTheAlgorithms:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7095 +/- ##
============================================
+ Coverage 78.50% 78.51% +0.01%
- Complexity 6752 6756 +4
============================================
Files 759 760 +1
Lines 22402 22413 +11
Branches 4400 4402 +2
============================================
+ Hits 17587 17598 +11
Misses 4109 4109
Partials 706 706 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Implemented ArmstrongNumber.isArmstrong() method - Added comprehensive unit tests for Armstrong numbers - Includes documentation with examples - Handles edge cases (negative numbers, zero) - Tests cover known Armstrong numbers: 0, 1, 153, 370, 371, 407, 1634 Signed-off-by: duvvuvenkataramana <venkataramana2048@gmail.com>
- Added explicit cast from double to int for Math.pow result - Resolves 'implicit cast is possibly lossy' compiler warning - Project uses -Werror flag which treats warnings as errors Signed-off-by: duvvuvenkataramana <venkataramana2048@gmail.com>
|
This pull request has been automatically closed because its workflows or checks failed and it has been inactive for more than 14 days. Please fix the workflows and reopen if you'd like to continue. Merging from main/master alone does not count as activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds an Armstrong Number (Narcissistic Number) algorithm implementation with comprehensive unit tests.
Changes Made
ArmstrongNumber.isArmstrong()methodAlgorithm Explanation
An Armstrong number equals the sum of its digits each raised to the power of the number of digits.
Example: 153 = 1³ + 5³ + 3³ = 1 + 125 + 27 = 153
File Structure
src/main/java/com/thealgorithms/maths/ArmstrongNumber.java- Main algorithmsrc/test/java/com/thealgorithms/maths/ArmstrongNumberTest.java- Unit testsType of Change