Python program to find strong numbers in a list

In this tutorial, we will learn how to find strong numbers in a list in Python.

Basically, Python is a high programming level language.
A list is a data type in python which consists of various data separated by a comma. Here is the code to find out strong numbers in a list. If the summation of all the digits’s factorial is same as the number itself then we can say that the number is a strong number. This is the condition to be a strong number. Let’s make it easy with the below example.
Eg 145 here the digits are 1,4 and 5 so factorial of 1 is, 4! is 24 and 5! is 120 after adding 1+24+120=145.

Code: Find strong numbers in a list in Python

def factorialCalculation(num):
if (num == 0 or num == 1):
fact = 1
fact = num * factorialCalculation(num - 1)
return fact

print("The Strong number in List are:")
listofvalue = [1, 2, 9,28, 32 ,145, 427]
for i in listofvalue:
temp = i
sum = 0
while (temp):
rem = temp % 10
sum += factorialCalculation(rem)
temp = temp // 10
if (sum == i):



The Strong number in List are:


So for coding, we will first take a recursive function for calculating the factorial.
After taking the input list from the user we will extract digit by digit and pass the value to factorial
function after returning the factorial we will add up and compare it with the original number.
So the number is equal to the sum of the factorial of its digit it is a strong number we will print it.

Also read:

Leave a Reply

Your email address will not be published. Required fields are marked *