Check if a Number is a Spy Number

Given a positive integer n, return true when the sum of its decimal digits equals the product of its decimal digits; otherwise return false. A number…

Given a positive integer `n`, return `true` when the sum of its decimal digits equals the product of its decimal digits; otherwise return `false`. A number satisfying this condition is called a spy number.

- `1 ≤ n ≤ 10^9` - `n` is always a positive integer.

Example 1: input n = 1124; output true. The digit sum and product are both 8.

Example 2: input n = 124; output false. The digit sum is 7 while the product is 8.

Example 3: input n = 101; output false. The digit sum is 2 while the product is 0.

Category: Math. Topic: math. Difficulty: Easy. Patterns: math.