Skip to content

Commit

Permalink
Create Check if Armstrong Number
Browse files Browse the repository at this point in the history
  • Loading branch information
madhavcodes authored Oct 2, 2021
1 parent fc53a47 commit 82f0d23
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Check if Armstrong Number
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int(input("Enter a number: "))

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10

# display the result
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")

0 comments on commit 82f0d23

Please sign in to comment.