how to check if a number is armstrong in python

Solutions on MaxInterview for how to check if a number is armstrong in python by the best coders in the world

showing results for - "how to check if a number is armstrong in python"
Regina
09 Jul 2016
1num = 1634
2
3# Changed num variable to string, 
4# and calculated the length (number of digits)
5order = len(str(num))
6
7# initialize sum
8sum = 0
9
10# find the sum of the cube of each digit
11temp = num
12while temp > 0:
13   digit = temp % 10
14   sum += digit ** order
15   temp //= 10
16
17# display the result
18if num == sum:
19   print(num,"is an Armstrong number")
20else:
21   print(num,"is not an Armstrong number")
22
Silvana
07 Aug 2020
1# Python program to check if the number is an Armstrong number or not
2
3# take input from the user
4num = int(input("Enter a number: "))
5
6# initialize sum
7sum = 0
8
9# find the sum of the cube of each digit
10temp = num
11while temp > 0:
12   digit = temp % 10
13   sum += digit ** 3
14   temp //= 10
15
16# display the result
17if num == sum:
18   print(num,"is an Armstrong number")
19else:
20   print(num,"is not an Armstrong number")
21
Daniela
19 Jun 2016
1# Program to check Armstrong numbers in a certain interval
2
3lower = 100
4upper = 2000
5
6for num in range(lower, upper + 1):
7
8   # order of number
9   order = len(str(num))
10    
11   # initialize sum
12   sum = 0
13
14   temp = num
15   while temp > 0:
16       digit = temp % 10
17       sum += digit ** order
18       temp //= 10
19
20   if num == sum:
21       print(num)
22
queries leading to this page
how to check if a number is armstrong in python4 digit armstrong number in pythonarmstrong pythonarmstrong function in pythondetermine whether a number is a perfect number 2c an armstrong number or a palindrome check a number is armstrong or not in python for any numbercheck number is armstrong or not in python gfgarmstrong program in pythongiven number is armstrong or not in pythonprogram to find armstrong number in pythonarmstrong number in python programizpython program to generate armstrong numberscheck whether a given number is armstrong number in pythonhow to print armstrong no in pythonprogram to check whether number is armstrong or not in pythonarmstrong numberin pythoncheck number is armstrong or not in python armstrong number series in pythonprogram to check armstrong number in pythonpython program to check whether a number is armstrong number or notarmstrong number in python easy programarmstrong number program in pythonarmstrong in pythonwrite a python program to check whether the number is armstrong number or not using function 3apython armstrong programpython program for armstrong numbergenerate armstrong number in pythonarmstrong number check in pythonarmstrong number python doselectpython code to check armstrong numberarmstrong number function python doselectwrite a python program to check whether a number is armstrong number or not in pythonwrite python program to fined if given number is armstrong numberarmstrong numbers in pythonhow to check whether a number is armstrong or not in pythonarmstrong numbers pythoncheck the number is armstrong or not in pythonarmstrong number in python logichow to find armstrong number in pythoncheck whether a number is armstrong or not in pythonarmstrong method python codepython code for armstrong numbercheck armstrong number in pythonarmstrong number function in pythonread a no and display whether its is armstrong or not in pythonarmstrong number program in python using functionarmstrong number in pythonarmstrong number python functionpython write a program to determine armstrong numberarmstrong python program10 how would check a number is armstrong number using python 3farmstrong number code in pythoncheck a number is armstrong or not in pythonpython armstrong numberwhat is armstrong number logic pythonarmstrong number or not in pythonarmstrong number within given number program in pythonhow to find the armstrong number in pythonwrite python program to fine armstrong numberpython program armstrong numberarmstrong code in pythonpython function for armstrong numberarmstrong number python 1634armstrong of a number in pythoncheck armstrong number python programmingpython program to check armstrong numberarmstrong number in python youtuvhow to find given number is a armstrong number or not in pythonpython program to check given number is armstrong or notpython code to show that number is armstrong number or not 28for n numbers 29 to find whether a given number is armstrong number or not in pythonwrite python program to check armstrong number python what is armstrong numberswrite a python program to check armstrong number 3farmstrong number in python2armstrong without using loop pythonprogram for armstrong number in pythonpython program to check for armstrong numberarmstrong numer code in python2 develop a python program to check the given number is armstrong number or not using iteration control structures armstrong number in python using while loopwrite a program in python to check whether the given number is armstrong or not find armstrong number in pythoncheck for armstrong number in pythonis armstrong number in pythonimplement python script to check given number is armstrong or not python armstrong number checkerpython program to find if a number is armstrong or notis armstrong is function available in pythongiven an integer n 2c check whether it 27s an armstrong number or not pythonpython code to find armstrong numberpython program for armstrong number using functionsarmstrong number pythonpython program to check armstrong number using functionsarmstrong num code in pythonarmstrong or not in pythonarmstrong number program pythonarmstrong number in pythonarmstrong no in pythonhow to check if number is armstrong number in pythonarmstrong number in python using functionarmstrong number program in python explanationwrite a program to find armstrong numbers in pythonisarmstrong pythonwhat is armstrong number in pythonhow to check if a number is armstrong in python