Strong Number
A number is called a Strong Number if the sum of the factorials of its digits equals the original number.
ex: 145 =====> 1! + 4! + 5! ====>1 + 24 + 120 ===> 145
def findfactorial(n):
fac=1
while n>0:
fac*=n
n-=1
return fac
def IsStrongNo(num):
total = 0
while num>0:
last=num%10
factorial=findfactorial(last)
total+=factorial
num//=10
return total
num=int(input("ENter a num"))
result=IsStrongNo(num)
if result==num:
print("Strong Number")
else:
print("Not a Strong Number")
input : 145
Duck number
A Duck Number is a number that contains at least one 0, but must not start with 0
no = input("Enter no: ")
if no[0] == '0':
print("Not a Duck Number")
else:
if '0' in no:
print("Duck Number")
else:
print("Not a Duck Number")


Top comments (0)