March 07, 2021

strong number using python

 Strong number is a special number whose sum of factorial of digits is equal to the original number. For example: 145 is strong number. Since, 1! + 4!

IDLE view : 













source code :

#strong number 145

def fact(n):    #calculating factorial 

    if (n>0):

        return (n*fact(n-1))

    else:

        return (1)

#strong number  code

add=0

num=input("enter the number : ")

l=(len(num))

for i in range(0,l):

    add=add+fact(int(num[i]))

if int(num)==add:

    print(f"{num} is strong number ")

else:

    print (f"{num} is not strong number ")

    



No comments:

Post a Comment

find the cube of the range given digits. || codeAj

Find the cube of the range given Digits. Source Code r= int ( input ( "enter the range of digit : " )) def number_conter (n): ...