Armstrong Number Function

A positive integer is called an Armstrong number of order n if 

abcd... = a**n + b**n + c**n + d**n + ... 

Here, n is number of digits in the given positive number. 

In case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example:

153 = 1**3 + 5**3 + 3**3  # 153 is an Armstrong number.

Write a function is_armstrong(n): It tests if n is an Armstrong number (True) or not (False).  

Examples

is_armstrong(153) ➞ True
is_armstrong(1) ➞ True
is_armstrong(123) ➞ False

Note: 

  • Writing a function is compulsory for this problem. Use "is_armstrong" as a function name.
  • Don't forget to return the result.




Login is required