Prime

#### Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

#### Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

# Checking Strong number or not using Python

## Strong number

Strong numbers are the special numbers whose sum of factorial of the digits is equal to the number itself.In this program we will be find the factorial of individual digits of a number and sum them.Later we will be check whether the sum is equal to the given number.If equal then number is strong number,otherwise not.The strong numbers in the range 1 to 1000 are 1, 2, 145

Example : n=145,

• Sum of factorials of digits 1, 4, 5= 145
• 145 is a Strong number

## Algorithm

• Input number and initialize sum of factorials to zero
• Find the factorials of individual digits and add them to sum of factorials
• If sum of factorials is equal to the given number,print “Strong number”
• else print “Not Strong number”

## Python code:

def factorial(n):
if(n<=1):
return 1
else:
return n*factorial(n-1)
num=int(input(“Enter any number”))
sumf=0
p=num
while(num>0):
sumf+=factorial(num%10)
num=num//10
if(p==sumf):
print(“Strong number”)
else:
print(“Not strong number”)

## Output:

Enter any number 5
Not strong number