number = 371
      num = number
      digit, sum = 0, 0
      length = len(str(num))
      for i in range(length):
        digit = int(num%10)
        num = num/10
        sum += pow(digit,length)
      if sum==number:
        print("Armstrong")
      else:
        print("Not Armstrong")
      
      Python language logo

      Find a Number is Armstrong or not

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.