Write a program in Java to check whether a given number is Spy number or not.

A Spy number is a number whose sum of digits is equal to the product of its digits, Example – 1124.

Spy number Example

So to check spy number in Java we need to follow the following steps.

  • Input a number.
  • Calculate the sum of its digits (sum).
  • Calculate the product of the same input number (product).
  • If sum == product then its a Spy number else not.

Let’s implement the same in Java.

Output

If you have any doubts or suggestion then comment below.

Leave a Reply

Close Menu