Spy Number

Spy Number is a number whose sum of digits and product of digits are equal.

Example 1: 22. 2+2 = 2*2 = 4. Hence it is a Spy Number.

Example 2: 44. 4+4 ≠ 4*4. Here the sum of digits is not equal to the product of digits. Hence it is not a Spy Number.

Java
import java.util.*;
public class SpyNumberRange
{
    public static void main(String args[])
    {
        int n=0,r=0,s=0,p=1,nCopy=0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a number: ");
        n=sc.nextInt();
        nCopy=n;
        while(n>0)
        {
            r=n%10;
            s=s+r;
            p=p*r;
            n=n/10;
        }
        if(s==p)
        {
            System.out.println(nCopy+" is a Spy Number");
        }
        else
        {
            System.out.println(nCopy+" is not a Spy Number");
        }
    }
}
Java