Code is copied!
Program To Print Spy Number JAVA
Write a Program to print whether the inputted number is Spy or not.
[A positive integer is called a spy number if the sum and product of its digits are equal. Example : 132 sum of digits : 1 + 3 + 2 = 6 , product of digits = 1*2*3 = 6]
import java.util.*; class spy { public static void main(String args[]) { Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int prod = 1,sum =0; while (n>0) { int digit = n % 10; sum = sum + digit; prod = prod * digit; n=n/10; } if(prod == sum) { System.out.println("yes it is spy number"); } else { System.out.println("No it is not spy"); } } }