Find a Number is Armstrong or not

    0

    0

    CrypticSai-08

    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")
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.