Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

armstrong python

def check_if_armstrong():
    number = input("Enter number: ")
    
    sum_of_cube = 0
    for i in range(len(number)):
        sum_of_cube = sum_of_cube + pow(int(number[i]), 3)
    print(sum_of_cube)
    
    if int(number) == sum_of_cube:
        print(f'{number} is armstrong')
    else:
        print(f'{number} isn't armstrong')
        
check_if_armstrong()
Source by www.scaler.com #
 
PREVIOUS NEXT
Tagged: #armstrong #python
ADD COMMENT
Topic
Name
9+2 =