Computer Science, asked by Xxxxx11111, 1 year ago

Program to cheack wheather a number is a spy number or not

Answers

Answered by Anonymous
2
A spy number is that the sum of its digits is equal to the product of its digits.

// This program is to check whether a number is spy number or not
public class Spy-number
{
public void accept(int n)
{
int rem'sum=0,pro=1;
while(n!=0)
{
rem=n%10;
n=n/10;
sum = sum+rem;
pro = pro*rem;
}
if(sum==pro)
System.out.println("The given number is spy number");
else
System.out.println("The given number is not a spy number");
}
}

Here
variable n      :for accepting from user
              rem :is for remainder
              sum :is for sum
              pro   :is for product
Similar questions