Skip to content

Instantly share code, notes, and snippets.

@jatinsharrma
Created July 13, 2019 19:48
Show Gist options
  • Save jatinsharrma/50d942461d5d19cdbd3eb7b771b78ca3 to your computer and use it in GitHub Desktop.
Save jatinsharrma/50d942461d5d19cdbd3eb7b771b78ca3 to your computer and use it in GitHub Desktop.
Strong Number (eg 145 = 1! + 4! + 5!)
#Write a Python function to find all the Strong numbers in a given list of numbers.
def factorial(number):
if number == 1:
return (number)
elif number == 0:
return 1
else:
return (number * factorial(number-1))
def find_strong_numbers(num_list):
result = []
for num in num_list:
temp = str(num)
answer = 0
for t in temp:
answer = answer + factorial(int(t))
if num == answer:
result.append(num)
return (result)
num_list=[145,375,100,2,10]
strong_num_list=find_strong_numbers(num_list)
print(strong_num_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment