We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db193cd commit 6604830Copy full SHA for 6604830
Programs/P81_armstrong number.py
@@ -0,0 +1,31 @@
1
+# Python program to check if the number is an Armstrong number or not
2
+
3
+# take input from the user
4
5
+num = int(input("Enter a number: "))
6
7
+# initialize sum
8
9
+sum = 0
10
11
+# find the sum of the cube of each digit
12
13
+temp = num
14
15
+while temp > 0:
16
17
+ digit = temp % 10
18
19
+ sum += digit ** 3
20
21
+ temp //= 10
22
23
+# display the result
24
25
+if num == sum:
26
27
+ print(num,"is an Armstrong number")
28
29
+else:
30
31
+ print(num,"is not an Armstrong number")
0 commit comments