Skip to content

Commit e4ef548

Browse files
committed
armstrong number bug fix
1 parent 609441d commit e4ef548

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

armstrong.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
__author__ = 'Avinash'
22

33
input_num = (input("Enter any number: "))
4+
digit_len = len(str(input_num))
45

56
try:
67
arm_num = 0
78
val = int(input_num)
89
while val > 0:
910
reminder = val % 10
10-
arm_num += reminder ** 3
11+
arm_num += reminder ** digit_len
1112
val //= 10
1213

1314
if int(input_num) == arm_num:

0 commit comments

Comments
 (0)