# 15+ Python Armstrong Checker & Finder Examples

This post contains a total of 15+ Hand-Picked Python Armstrong Number Checker & Finder Program Examples with Source Code. All the Armstrong Number Checker & Finder programs are made using Python Programming Language.

You can use the source code of these programs for educational purpose with credits to the original owner.

### Related Posts

Click a Code to Copy it.

## 1. By Mert YazΔ±cΔ±

Made by Mert YazΔ±cΔ±. Python program to check if a number is Armstrong or not. ( Source )

```371
371 is armstrong number.
3**3 + 7**3 + 1**3 =
27 + 343 + 1 =
371 = 371```
``````i = input()
sum = 0
for a in i:
sum += int(a)**len(i)
print(i + " is"+ int(not sum==int(i))*" not"+" armstrong number.")
print((" + ".join(i for i in (a + "**" + str(len(i)) for a in i)) + " =\n" + " + ".join(i for i in (str(int(a)**len(i)) for a in i)) + " =\n" + str(sum)).strip() + (' =' + '/='*(sum!=int(i))), i)``````

## 2. By Infant Raj

Made by Infant Raj. Program in python to find all the Armstrong numbers from 0 to 1000. ( Source )

```0 Is an Armstrong Number
1 Is an Armstrong Number
2 Is an Armstrong Number
3 Is an Armstrong Number
4 Is an Armstrong Number
5 Is an Armstrong Number
6 Is an Armstrong Number
7 Is an Armstrong Number
8 Is an Armstrong Number
9 Is an Armstrong Number
153 Is an Armstrong Number
370 Is an Armstrong Number
371 Is an Armstrong Number
407 Is an Armstrong Number```
``````#looping the numbers from 0 to 1000
for i in range(0,1000):
if int(i) < 1000 :

# length of the number
new = len(str(i))

#running total
total = 0

#finding the cube of each digit
newNum = i
while int(newNum) > 0:
temp = int(newNum) % 10
total += temp ** new

(newNum) //= 10

#if you want to filter the single          digit numbers
#singleDigit = [2,3,4,5,6,7,8,9]

#output the result
if i == total: #and i not in singleDigit:
print(i, "Is an Armstrong Number")
"""
else:
print(i, "Is NOT")
"""  ``````

## 3. By πβ’β¦ββ£βπ

Made by πβ’β¦ββ£βπ. ( Source )

```Your entered number:370
It is armstrong```
``````num=int(input("Your entered number:"))
print(num)
sum=0
temp=num
while temp>0:
digit=temp%10
sum+=digit**3
temp//=10
if num==sum:
print("It is armstrong")
else:
print("")``````

## 4. By David Ashton

Made by David Ashton. ( Source )

```34
34 is not an Armstrong Number.```
``````
def is_an(n):
"""Check for Armstrong Number."""
return int(n) == sum(int(d)**3 for d in n)

n = input() or "407"

print(f"{n} is{' ' if is_an(n) else ' not '}an Armstrong Number.")``````

## 5. By Python World

Made by Python World. ( Source )

```Enter a no: 153
153 is armstrong no```
``````num =int(input("Enter a no: "))

#initialize
sum =0

temp= num

while temp>0:
digit =temp%10
sum+=digit**3
temp//= 10
if num == sum:
print (num,"is armstrong no")
else:
print(num,"is not armstrong no")``````

## 6. By SΓ’Γ±tΓ΄sh

Made by SΓ’Γ±tΓ΄sh. ( Source )

```45
not armstrong number```
``````x = input();sum=0
for i in range(len(x)):
y=int(x[i])**3
sum+=y
print("Armstrong Number"if int(x)==sum else "not armstrong number")
``````

## 7. By ApidBoy

Made by ApidBoy. This Program Simply Tells You That Whether A Number Is An Armstrong Or Not. ( Source )

```345
No, 345 Is Not An Armstrong Number```
``````#Taking Input From User In Integral Form
number = int(input())
#Defining A Variable And Assigning Value "0" To It
x = 0
#Conserving The Value Of Variable "number" In Variable "y"
y = number
#Creating A While Loop
while number>0:
#To Get The Number In Tense, Hundreath, etc Places, Using Modulus To Get Remainder
z = number%10
#Getting The Cubes Of The Number Modded By 10 Above
x = x+z*z*z
#Performing Floor Division To Get Exact Value Of The Number
number = number//10
#If The Number Conserved Above Is Equal To The Number Present In Variable "y" Then, The Number Will Be An Armstrong Number
if y==x:
print("Yes,",y,"Is An Armstrong Number")
#And If Not Then It Will Not Be An Armstrong Number
else:
print("No,",y,"Is Not An Armstrong Number")

#Code Ends....``````

## 8. By π Prometheus πΈπ¬

Made by π Prometheus πΈπ¬. ( Source )

```370
Armstrong number!```
``a=int(input());print("Armstrong number!") if sum(list(map(lambda x:int(x)**3,list(str(a)))))==a else print("Not an Armstrong number!")``

## 9. By scientist

Made by scientist. Simple Armstrong number checker python program. ( Source )

```==##Finding Whether Entered Number##==
==##  is Armstrong Number or Not  ##==
Enter a three digit number: 234

""Calculation""

Hundreds digit is  2.0
Its cube is  8.0

Tens digit is  3.0
Its cube is  27.0

Ones digit is  4
Its cube is  64

Your entered three digit number 234  is not an Armstrong number.```
``````print ("==##Finding Whether Entered Number##==\n==##  is Armstrong Number or Not  ##==")

num=int(input("Enter a three digit number: "))

a=num%100
b=a%10

h_dig=(num-a)/100
t_dig=(a-b)/10
o_dig=b

print(num)
print("\n \"\"Calculation\"\"")

print("\n Hundreds digit is ", h_dig)
print(" Its cube is ",(h_dig)**3)

print("\n Tens digit is ", t_dig)
print(" Its cube is ",(t_dig)**3)

print("\n Ones digit is ", o_dig)
print(" Its cube is ",(o_dig)**3)

if (h_dig)**3 + (t_dig)**3 + (o_dig)**3 == num :
print("\n Your entered three digit number", num, " is an Armstrong number.")
else :
print("\n Your entered three digit number", num, " is not an Armstrong number.")
``````

## 10. By David Ashton

Another Armstrong checker program by David Ashton to get all the Armstrong number in a given range. ( Source )

` Armstrong Numbers to 2222 = 1, 153, 370, 371, 407`
``````
def is_an(n):
'''Check for Armstrong Number.'''
return int(n) == sum(int(d)**3 for d in n)

n = input() or "500"
print(f"Armstrong Numbers to {n} = ", end="")
print(*[i for i in range(1, int(n) + 1) if is_an(str(i))], sep=", ")``````

## 11. By Ben

Made by Ben. ( Source )

```Give a number: 407
The number 407 is a Armstrong number```
``````number = str(input("Give a number: "))
armstrong = int(number)
sum = 0
for i in number:
sum += int(i) ** 3
if sum == armstrong:
print("The number " + str(armstrong ) +" is a Armstrong number")``````

## 12. By David

Made by David. ( Source )

```234 is not an Armstrong Number because:
number of digits = 3
2^3 + 3^3 + 4^3 = 99

Armstrong Numbers to 234 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 153```
``````def is_an(n):
'''Check for Armstrong Number.'''
global digits
global total
return int(n) == (
total := sum(int(c)**(digits := len(n))
for c in n)
)
# more readable is:
# digits = len(n)
# total = sum(int(c)**digits for c in n)
# return int(n) == total

n = input() or "548834"

print(f"{n} is{' ' if is_an(n) else ' not '}an Armstrong Number because:")
print("number of digits =", digits)
for c in n[:digits - 1]:
print(f"{c}^{digits} + ", end="")
print(f"{n[-1:]}^{digits} = {total}")

print()

print(f"Armstrong Numbers to {n} = ", end="")
print(*(i for i in range(1, int(n)+1) if is_an(str(i))), sep=", ")``````

## 13. By Tomiwa Joseph

Made by Tomiwa Joseph. Simple python program to find if a number is Armstrong or not, the program also prints all the Armstrong numbers that exist to that range. ( Source )

```Is 307 an Armstrong number?	 False

How? π€
Each element in 307 raised to the power of 3 is [27, 0, 343]
Addition of each element raised to power is 370

Is 370 equal to 307 ?	 False

Bonus challenge
All the Abundant numbers within the given range 0 to 307 are:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153]

```
``````def armstrong(number):
#convert each element in the input to an integer and raise it to the power of the length
raised = [int(i)**len(number) for i in number]
#compare the addition to the number
return addition == int(number)

#enter your number or just press submit. The default number will be used
your_number = input() or '370'
print("Is",your_number,"an Armstrong number?\t",armstrong(your_number))

#Explanation variables
raised = [int(i)**len(your_number) for i in your_number]

print("\nHow? π€")
print("Each element in",your_number,"raised to the power of",len(your_number),"is",raised)
print("Addition of each element raised to power is",sum(raised))

print("\nIs",sum(raised),"equal to",int(your_number),"?\t",sum(raised) == int(your_number))

print("\n\nBonus challenge")
print("All the Abundant numbers within the given range 0 to",your_number,"are:\n")

#iterate through the range and for each element try it with the abundant function, if it returns True, add to the list, else, look awayπ
print([i for i in range(int(your_number)+1) if armstrong(str(i))])

print("\nBonus - Two-liner for an interested somebodyπ₯")

print("""\ndef armstrong(number):
return sum([int(i)**len(number) for i in number]) == int(number)""")

print("\n\nHappy coding ππ")
print("Do upvote if you like π·π€")``````

## 14. By Janusz Bujak π΅π± πΊπ¦

Made by Janusz Bujak π΅π± πΊπ¦. ( Source )

```407
407 is the Armstrong number.
233168```
``````x = input() or '407'  # 4Β³+0Β³+7Β³
y = sum(int(c)**len(x) for c in x)
print(x, 'is' if int(x)==y else 'is not', 'the Armstrong number.')

# Project Euler 1
print(sum([x for x in range(1000) if x%3==0 or x%5==0]))``````

## 15. By F1

Made by F1. Prints all the Armstrong numbers in a given range. ( Source )

```999
0
1
2
3
4
5
6
7
8
9
153
370
371
407```
``````nums = []

def armstrong(x):
sum = 0
for i in str(x):
sum += int(i)**len(str(x))
if sum == x:
nums.append(x)

for i in range(int(input())):
armstrong(i)

for i in nums:
print(i)``````

## 16. By Samarth

Made by Samarth. ( Source )

```777
The Number 777 Is Not An Armstrong Number!```
``````n = int(input())
a = list(map(int,str(n)))
b = list(map(lambda x:x**3,a))
if (sum(b)==n):
print("The Number",n,"Is An Armstrong Number!")
else:
print("The Number",n,"Is Not An Armstrong Number!")``````