write a program in java to find if a number is special number or not. Give the output. Thnx
Answers
Answered by
1
Answer:
you should download a app phdroid....it willl help you
Answered by
1
Explanation:
A special number is said to be when the sum of factorial of its digit
is equal to number itself.
Ex: 145
1!+4!+5!=145.
import java.util.*;
public class Special_no_java
{
public static void main(String args[])
{
Scanner sc =new Scanner(System.in);
System.out.println(“Enter your number”);
int no=sc.nextInt();
int check=no,mod=0,fact=1,sum=0;
while(no!=0)
{
mod=no%10;
no=no/10;
fact=1;
for(int i=mod;i>0;i--)
{
fact=fact*i;
}
sum=sum+fact;
}
if(check==sum)
{
System.out.println("this is special number:"+sum);
}
else
{
System.out.println("this not special number:"+sum);
}
}
}
Similar questions
Math,
5 months ago
India Languages,
5 months ago
English,
5 months ago
Environmental Sciences,
10 months ago
Science,
10 months ago
English,
1 year ago
English,
1 year ago