JuniorMath
Subtract the Product and Sum of Digits of an Integer
Given an integer number n, return the difference between the product of its digits and the sum of its digits.
Example 1
Input
n = 234Output
15Product of digits is 2 * 3 * 4 = 24, sum of digits is 2 + 3 + 4 = 9, and 24 - 9 = 15.
Example 2
Input
n = 4421Output
21Product of digits is 4 * 4 * 2 * 1 = 32, sum of digits is 4 + 4 + 2 + 1 = 11, and 32 - 11 = 21.
Constraints
- 1 <= n <= 10^5