Kodekraftt
/Blog
/Strong Number In Java
Join Early AccessContact UsPrivacy Policy
Java BasicsOOPsDSA with JavaQuizzesInterview Preparation

© 2026 KodeKraftt. All rights reserved.

Build smarter. Learn more. Innovate better.

Strong Number in Java

Learn what a Strong Number is, how it works, and how to write an efficient Java program to check if a number is strong. Includes explanation, examples, algorithm, and clean Java implementation.

Strong Number in Java

A Strong Number is a number in which the sum of the factorial of each digit is equal to the number itself. These numbers are quite rare, and they demonstrate the usefulness of factorial operations in algorithmic problem solving.

What Is a Strong Number?

A number is considered strong if:


Sum of factorials of digits = Original number

For example:


145 → 1! + 4! + 5!
   → 1 + 24 + 120
   → 145 (Strong Number)

So, 145 is a Strong Number because the sum of factorials of its digits gives back the same number.

Examples of Strong Numbers

  • 1
  • 2
  • 145
  • 40585

Algorithm to Check Strong Number

  1. Take input number.
  2. Extract each digit using modulus %.
  3. Find factorial of each digit.
  4. Add all factorial values.
  5. If sum equals the original number → it is a Strong Number.

Java Program to Check Strong Number


public class StrongNumber {

    // Method to find factorial of a digit
    static int factorial(int n) {
        int fact = 1;
        for (int i = 1; i <= n; i++) {
            fact *= i;
        }
        return fact;
    }

    public static void main(String[] args) {
        int num = 145;
        int temp = num;
        int sum = 0;

        while (temp > 0) {
            int digit = temp % 10;
            sum += factorial(digit);
            temp /= 10;
        }

        if (sum == num) {
            System.out.println(num + " is a Strong Number.");
        } else {
            System.out.println(num + " is NOT a Strong Number.");
        }
    }
}

Output


145 is a Strong Number.

Conclusion

Strong Numbers illustrate how digit-based mathematical patterns can be identified using factorial operations. Though rare, they are a great practice problem for beginners learning loops, digits extraction, and basic algorithms in Java.

You might also like

Odious Number in Java: Definition, Rules, Examples, and Practice Problems

Learn what an Odious Number is in Java and number theory. Understand its definition, binary representation rules, examples, and how to check Odious Numbers using Java. Includes example table and 3 practice challenges.

Evil Number in Java: Definition, Examples, and Practice Problems

Learn what an Evil Number is in Java and number theory. Understand its definition, binary representation rules, examples, and how to check Evil Numbers using Java. Includes example table and 3 practice challenges.

Sunny Number in Java: Meaning, Explanation, Examples, and Practice Problems

Learn what a Sunny Number is in Java with definition, examples, logic, and a complete Java program. Understand how to check Sunny Numbers and practice with 3 coding challenges for students.

Buzz Number in Java: Definition, Rules, Examples, and Practice Problems

Learn what a Buzz Number is in number theory and Java programming. Understand its rules, examples, and how to check Buzz Numbers using Java. Includes sample program, table of examples, and 3 practice challenges.

100 Java Programs for Beginners with Examples and Solutions

Explore 100 Java programs for beginners with explanations, logic, and examples. Learn Java step by step through number programs, string programs, pattern problems, mathematical logic, and practical coding exercises.

Duck Number in Java: Definition, Rules, Examples, and Practice Problems

Learn what a Duck Number is in Java programming. Understand its rules, see examples, and learn how to check a Duck Number using Java. Includes 3 detailed practice challenges.