guys Pls help me out....
what is a special number.? somewhere it is written that a special number is such that when the sum of the digits of the number is added to the product of its digits, the result is equal to the original number.
in other place it is... . A number is said to be special number when the sum of factorial of its digits is equal to the number.
Answers
Answered by
47
A special number is a number whose sum of factorial of digits is equal to the number .
CODE :-
import java.util.*;
class special_number
{
public void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number to check whether it is special number or not");
int n=sc.nextInt();
int d=0;
int cpy=n;
int s=0;
while(n>0)
{
d=n%10;
int f=1;
for(int i=1;i<=d;i++)
{
f=f*i;
}
s=s+f;
n=n/10;
}
if(s==cpy)
{
System.out.println("Special number");
}
else
{
System.out.println("Not a special number");
}
}
}
DON'T WORRY .
It will be given in the question paper what is a special number .
So no worries .
Study the theory and logical portion nicely instead of worrying about these things .
Best of luck :)
Natharva:
please explain me, what u have written
Similar questions