Write a program to input a number and print whether the number is a special number or not.
Answers
Answered by
2
Answer:
import java.util.*;
class special
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,i,d,sum=0,fact=0;
System.out.print(“Enter an integer:”);
n=sc.nextInt();
i=n;
while(i>0)
{
d=i%10;
i/=10;
for(int a=1;a<=d;a++)
{
fact*=a;
}
sum+=fact;
fact=0
}
if(sum==n)
System.out.println(“Special Number”);
else
System.out.println(“Not a Special Number”);
}
Similar questions
Math,
3 months ago
English,
3 months ago
Math,
3 months ago
Hindi,
6 months ago
Math,
6 months ago
Political Science,
10 months ago
Environmental Sciences,
10 months ago
Social Sciences,
10 months ago