A number is called Armstrong number when the sum of the nth power of each digit is equal to the given number.
If the Armstrong number is a positive integer of order n then it can be defined as,
abcde…. = pow (a, n) + pow (b, n) + pow (c, n) + pow (d, n) + pow (e, n) + ………
For example : 0, 1, 153, 370, 371, 1634 etc.
Let’s check whether 370 is an Armstrong number or not
370 = (3 * 3 * 3) + (7 * 7 * 7) + (0 * 0 * 0)
Here,
(3 * 3 * 3) = 27
(7 * 7 * 7) = 343
(0 * 0 * 0) = 0
27 + 343 + 0 = 370, which is equal to the given number; hence it is an Armstrong number.
Let’s check four digits Armstrong number:
1634 = (1 * 1 * 1 * 1) + (6 * 6 * 6 * 6) + (3 * 3 * 3 * 3) + (4 * 4 * 4 * 4)
Here,
(1 * 1 * 1 * 1) = 1
(6 * 6* 6 * 6) = 1296
(3 * 3 * 3 * 3) = 81
(4 * 4 * 4 * 4) = 256
1 + 1296 + 81 + 256 = 1634, which is equal to the given number; hence it is an Armstrong number.