DSA problem
Armstrong Number
Given an integer N, decide whether it is an Armstrong (narcissistic) number: a number equal to the sum of each of its digits raised to the power of the digit count. For example, 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153.
First count the number of digits d. Then extract each digit, raise it to the power d, and accumulate the total. If the total equals the original number, it is an Armstrong number.
Known examples include every single-digit number, plus 153, 370, 371, 407, 1634, 8208, and 9474. The problem reinforces digit-by-digit processing and highlights properties that depend on a number's representation, not just its value.
Examples
N = 153trueN = 123falseConstraints
- 0 <= N <= 10^9
3 hints and a full solution walkthrough with step-by-step visualizations are available in the practice editor.