 ### A number is known as Special number when sum of the factorial of digits is equal to the original number. It is also known as Krishnamurthy number. For example 1451!+4!+5!= 1+24+120= 145

###### For the factorial program click the link https://java4school.com/factorial-of-a-number

Write a program to accept a number and print whether it is a special number or not.

``````import java.io.*;
class SpecialNumber //one when the sum of factorial of its digits is = the number itself e.g., 145
{
public static void main()throws IOException {
System.out.println("Enter a number");
int fact=1;
int num=n;
int sum=0;
while(n!=0) {
int rem=n%10;
for(int i=1;i<=rem;i++)
{
fact*=i;
}
sum+=fact;
fact=1;
n=n/10;
}
if(num==sum)
{
System.out.println("It is a special number");
}
else
{
System.out.println("Its not a special number");
} } }
``````

Output:
Enter a number
145
It is a special number

#### For more number programs click the given link:https://java4school.com/number-programs-part-4-icse-computer-application

SHARE
Previous articleA basic Keith Number Program
Next articlePractice Test 1 class IX