“Armstrong Python” Respostas de código

Número de Armstrong Python

a = 1634
aa = str(a)
lenn = len(aa)
count = 0
for i in range(lenn):
    count +=  int(aa[i]) ** 4
if count == a :
    print("Yes")
else:
    print('No')
Kumaran KM

Número de Python Armstrong

number = 153
temp = number
add_sum = 0
while temp!=0:
    k = temp%10
    add_sum +=k*k*k
    temp = temp//10
if add_sum==number:
    print('Armstrong Number')
else:
    print('Not a Armstrong Number')
codelearner

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()
Suraj Kr Thapa

Respostas semelhantes a “Armstrong Python”

Perguntas semelhantes a “Armstrong Python”

Mais respostas relacionadas para “Armstrong Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código