Check Strong Number

Check whether a number is a strong number (sum of factorials of digits).

BeginnerTopic: Conditional Programs
Back

Python Check Strong Number Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# Program to check strong number

import math

num = int(input("Enter an integer: "))

total = 0
temp = num
while temp > 0:
    digit = temp % 10
    total += math.factorial(digit)
    temp //= 10

if total == num:
    print(num, "is a strong number")
else:
    print(num, "is not a strong number")
Output
Enter an integer: 145
145 is a strong number

Understanding Check Strong Number

A strong number equals the sum of factorials of its digits (e.g., 145 = 1! + 4! + 5!).

We extract digits with modulo and integer division, summing factorials.

Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.

Table of Contents