Subtract Product and Sum of Digits
EasyMath
Description
Given an integer n, return the product of its digits minus the sum of its digits. If n is negative, treat its digits as |n|.
Examples
Input:
n = 234Output:
15Explanation:
Digits are 2, 3, 4 with product 24 and sum 9, so the answer is 15.
Input:
n = 4421Output:
21Explanation:
Digits are 4, 4, 2, 1 with product 32 and sum 11, so the answer is 21.
Input:
n = 0Output:
0Explanation:
Single digit 0: product = 0, sum = 0, result = 0.
Input:
n = 10Output:
-1Explanation:
Digits are 1, 0 with product 0 and sum 1, so the answer is -1.
Constraints
- •
0 ≤ n ≤ 10⁹