Python Program to check a number is a strong number or not


In this program, You will learn how to check a number is a strong number or not in Python.


Some list are: 1, 2, 145, 40585

Example: How to check a number is a strong number or not in Python.

n = int(input("Enter a number:"))

num = n
s = 0
while n > 0:

    r = n % 10
    f = 1
    i = 1

    while i <= r:
        f = f * i
        i = i + 1

    s = s + f
    n = int(n / 10)

if s == num:
    print("This is a strong number:", num)
else:
    print("This is not a strong number:", num)

Output:

Enter a number:145
This is a strong number: 145