Check if a Number is Armstrong
Given an integer n, determine whether it is an Armstrong number.
An Armstrong number is a number that is equal to the sum of its digits, where each digit is raised to the power of the total number of digits.
Return true if the given number is an Armstrong number; otherwise, return false.
Example 1
Input
153
Output
true
Explanation
153 has 3 digits.
1³ + 5³ + 3³ = 1 + 125 + 27 = 153.
Since the sum is equal to the original number, 153 is an Armstrong number.
Constraints
Hints:
Hint 1
Count the number of digits in n. Extract each digit, raise it to the power of the total number of digits, and add the results. Compare the final sum with the original number.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Jul 20, 2026
Last updated
Aug 6, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output