Computer Science, asked by Anonymous, 8 months ago

what is the code of spy number in java programming....answer fast .......please

Answers

Answered by Anonymous
1

Answer:

A number is a Spy number, if sum and product of all digits are equal. Example: Number 123 is a Spy number, sum of its digits is 6 (1+2+3 =6) and product of its digits is 6 (1x2x3 = 6), sum and product are same, thus, 123 is a spy number.

Answered by AryaPriya06
3

Answer:

import java.io.*;

public class Number

public static void main (String args[])throws IOException

{

InputStreamReader read = new InputStreamReader(System.in);

BufferedReader in = BufferedReader(read);

int product = 1, sum = 0 , d;

while (n>0)

{

d = n%10;

sum = sum + d;

product = product *d;

n = n/10;

}

if (sum == product)

System.out.println(“Given number is a spy number”);

else

System.out.println(“Given number is not a spy number”);

}

}

Explanation:

Gud night and sweet dreams buddy❤️

Similar questions