![]() |
VOOZH | about |
A number is said to be a Spy number if the sum of all the digits is equal to the product of all digits.
Examples :
Input : 1412
Output : Spy Number
Explanation :
sum = (1 + 4 + 1 + 2) = 8
product = (1 * 4 * 1 * 2) = 8
since, sum == product == 8Input : 132
Output : Spy Number
Explanation :
sum = (1 + 3 + 2) = 6
product = (1 * 3 * 2) = 6
since, sum == product == 6
The number is a Spy number
Time Complexity: O(log10n)
Auxiliary Space: O(1)