Java
Java copied to clipboard
Add Armstrong Number algorithm with comprehensive tests
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 algorithmsrc/test/java/com/thealgorithms/maths/ArmstrongNumberTest.java- Unit tests
Type of Change
- [x] New algorithm implementation
- [x] Test cases added