def my_factorial(n):
b=1
for i in range(1,n+1):
b=b*i
return b
a=input("Enter a number")
for i in range(0,len(a)):
print(a[i])
my_sum=my_sum+my_factorial(int(a[i]))
Above line is kept inside the for loop. So on each step of the loop one digit of the number is used ( from left to right ). def my_factorial(n):
b=1
for i in range(1,n+1):
b=b*i
return b
a=input("Ener a number : ")
my_sum=0
for i in range(0,len(a)):
my_sum=my_sum+my_factorial(int(a[i]))
print("Sum of factorial of digits : ",my_sum)
if int(a)==my_sum:
print('This is a strong number : ', a)
else:
print('This is not a strong number', a)
def my_factorial(n):
b=1
for i in range(1,n+1):
b=b*i
return b
for a in range(10,100000): # change this range
my_sum=0
a1=str(a)
for i in range(0,len(a1)):
my_sum=my_sum+my_factorial(int(a1[i]))
if a==my_sum:
print('This is a strong number : ', a)
Output
This is a strong number : 145
This is a strong number : 40585
AUTHOR
🎥 Join me live on YouTubePassionate about coding and teaching, I love sharing practical programming tutorials on PHP, Python, JavaScript, SQL, and web development. With years of experience, my goal is to make learning simple, engaging, and project-oriented. Whether you're a beginner or an experienced developer, I believe learning by doing is the best way to master coding. Let's explore the world of programming together!