Computer Science, asked by jonam35, 6 months ago

Write a program to input a number and print whether the number is a special number or not.​

Answers

Answered by sneha12614
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