#4 - Armstrong number or not

What is Armstrong number?

N = 153
Total Digits = 3

= pow(1,3) + pow(5,3) + pow(3,3)
= 1 * 1 * 1 + 5 * 5 * 5 + 3 * 3 * 3
= 1 + 125 + 27
= 153

Example 1

Input: 153

Output: Armstrong number

N = 153
Total Digits = 3

= pow(1,3) + pow(5,3) + pow(3,3)
= 1 * 1 * 1 + 5 * 5 * 5 + 3 * 3 * 3
= 1 + 125 + 27
= 153

If result is same as N, it is armstrong number.

Example 2

Input: 123

Output: Not Armstrong number


Example 3:

Input: 1634

Output: Armstrong Number


Video Solution

Last updated