Computer Science, asked by rahul7880, 1 year ago

Wap to find given no is spy no or not?

Answers

Answered by choudhary21
4
\color{Black}{ \boxed{\bold{ \underline{Hii. Frd .Your .Answer}}}}

 <b>

 \huge {GOOD... MORNING}}

{\mathbb{CORRECT...ANSWER}}

✔program to accept a number and check and display whether it is a Spy Number or not.

A Number is spy number if the sum of its digits equals the product of its digits.

 Example : consider the number 1124

 Sum of the digits = 1 + 1 + 2 + 4

 Product of the digits = 1 * 1 * 2 * 4


\color{orange}{ \boxed{\bold{ \underline{ i .Hope .Help .You .jiiii}}}}
Attachments:
Answered by sirfria
0
A number is spy if sum of the digits = product of the digits
Here’s your Java programming

import java.io.*;
public class spy
{
public static void main(Stringargs[])throwsIOException
{
System.out.println(“enter any number “);
int n = Integer.parseInt(input.readLine);
int s=0,p=1,d,k;
k=n;
while ( n!=0)
{
d=n%10;
n=n/10;
s+=d;
p*=d;
}
if (s==p)
System.out.println(k+” is a spy number”);
}
}
Similar questions