An Effortless program Special Number
Write a program to accept a number and print whether it is a special number or not.
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 145
1!+4!+5!= 1+24+120= 145
For the factorial program click the link
Factorial of a number :Unleashed
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 {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int n=Integer.parseInt(br.readLine());
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 videos regarding java programming watch the video
https://www.youtube.com/watch?v=QZKcULOC4lg
For more number programs click the given link:
Masterful Important Number programs ICSE part-3
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.