Computer Science, asked by Sayani07, 11 months ago

write a program in java to find if a number is special number or not. Give the output. Thnx ​

Answers

Answered by abhik9780
1

Answer:

you should download a app phdroid....it willl help you

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