Strong number from n to m in python¶
In [7]:
n = int (input ('Enter the value of n: '))
m = int (input ('Enter the value of m: '))
if n > m:
temp = n
n = m
m = temp
print ('Strong numbers from ', n, ' to', m, ' are:')
for x in range(n, m + 1):
num = x
summ = 0
while num != 0:
r = num % 10
fact = 1
for i in range (1, r + 1):
fact = fact * i
summ = summ + fact
num = num//10
if x == summ:
print (x, end = ', ')
Enter the value of n: 1000 Enter the value of m: 1 Strong numbers from 1 to 1000 are: 1, 2, 145,
No comments:
Post a Comment