Problem: Write a Java program to check whether the given number is Special or not.

A number is said to be special if the sum of the factorial of its digits is equal to the original number. For example: 145.

Special Number

Steps to check special number in Java:

  1. Input a number.
  2. Find the factorial of its digits.
  3. Add all the factorials.
  4. Check if the computed sum is equal to the original number.
  5. If so then the number is special, otherwise not.

Here is the java program that implement the above steps to check special number:


Enter a number
Special number

Print all Special Numbers in the Range

To print all special numbers, we individually check each number in the given range whether it is special or not, and output them accordingly.

For this, we write the logic to check special number (same as used in the above program) in a separate function and use it for all numbers in the given interval.


Enter the lower and upper value of the Interval: 1 1000
1 2 145

In this programming example, we learned to check number using the Java programming language.

Leave a Reply

5 + 9 =