;

# Python Program to Print the Strong Numbers from 1 to Nth Number

###### Tutorialsrack 25/04/2020 Python

In this Python program, we will learn how to print the strong numbers from 1 to Nth number or in between a specific range.

## What is a Strong Number?

A Strong Number is a number in which the sum of the factorial of individual digits of that number is equal to the original number. For examples : 1, 2, 145, 40585, etc.

Now take a look at that example, we have a number 145 and its digits are 1, 4, and 5.

Now we find the factorial of each digit like we do

1! = 1 = 1

4! = 4*3*2*1 = 24

5! = 5*4*3*2*1 = 120

Now their sum = 120 + 24 + 1 = 145 which is equal to the Original Number.

Hence We can Say that 145 is a Strong Number.

Here is the source code of the program to print the strong numbers from 1 to Nth number or in between a specific range.

##### Python Program to Print the Strong Numbers from 1 to Nth Number
``````# Python Program to print Strong Numbers from 1 to Nth Number

# Import Module
import math

minValue = int(input("Enter the Minimum Value: "))
maxValue = int(input("Enter the Maximum Value: "))

totalStrongNo = 0

for Number in range(minValue, maxValue):
Temp = Number
Sum = 0
while(Temp > 0):
Reminder = Temp % 10
Factorial = math.factorial(Reminder)
Sum = Sum + Factorial
Temp = Temp // 10

if (Sum == Number):
print("%d is a Strong Number" %Number)
totalStrongNo = totalStrongNo + 1

if(totalStrongNo==0):
print("\nThere is No Strong Number Between {0} and {1}".format(minValue,maxValue))
``````
##### Output

Enter the Minimum Value: 1

Enter the Maximum Value: 1000000

1 is a Strong Number

2 is a Strong Number

145 is a Strong Number

40585 is a Strong Number