Java icon indicating copy to clipboard operation
Java copied to clipboard

Add Armstrong Number algorithm with comprehensive tests

Open duvvuvenkataramana opened this issue 3 months ago • 1 comments

Description

This PR adds an Armstrong Number (Narcissistic Number) algorithm implementation with comprehensive unit tests.

Changes Made

  • ✅ Implemented ArmstrongNumber.isArmstrong() method
  • ✅ Added detailed JavaDoc documentation with examples
  • ✅ Created comprehensive unit tests covering:
    • Known Armstrong numbers (0, 1, 153, 370, 371, 407, 1634)
    • Non-Armstrong numbers (10, 100, 152, 200)
    • Edge cases (negative numbers)
  • ✅ Follows project coding standards and package structure

Algorithm 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 algorithm
  • src/test/java/com/thealgorithms/maths/ArmstrongNumberTest.java - Unit tests

Type of Change

  • [x] New algorithm implementation
  • [x] Test cases added

duvvuvenkataramana avatar Nov 23 '25 13:11 duvvuvenkataramana

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 78.51%. Comparing base (f693c44) to head (31309a6).

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              

: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 Nov 23 '25 13:11 codecov-commenter

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.

github-actions[bot] avatar Dec 08 '25 03:12 github-actions[bot]