An Armstrong number, also called a narcissistic number, equals the sum of its digits each raised to the power of the digit count. 153 has 3 digits, and 1³ + 5³ + 3³ = 153.
Solve it in two passes, or one if you convert to a string:
- count the digits
k - peel each digit and add
digit^k
Then compare the total against the original value. A classic bug is comparing against n after you've already divided it down to 0, so save a copy first.