Wapto check whether a number is spy number or not
in blue j
Answers
Answered by
1
import java.io.*;
class Spy
{
public static void main(String args[])throws IOException
{
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);
System.out.print("Enter the number: ");
int n = Integer.parseInt(br.readLine());
int sum = 0;
int product = 1;
for(int i = n; i != 0; i /= 10)
{
int digit = i % 10;
sum += digit;
product *= digit;
}
if(sum == product)
System.out.println("Spy number.");
else
System.out.println("Not spy number.");
}
}
Similar questions
Math,
6 months ago
English,
6 months ago
Math,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago