Compute the difference between the product of an integer's digits and the sum of its digits.
Subtract Product and Sum of Digits
gfgGiven a positive integer , consider the digits of individually. Compute:
Return the value of product - sum.
The task is purely about digit-by-digit processing and simple arithmetic.
Example 1
Input
n = 234
Output
15
Explanation
Digits are 2, 3, and 4. Product = 2 × 3 × 4 = 24. Sum = 2 + 3 + 4 = 9. Difference = 24 - 9 = 15.
Example 2
Input
n = 4421
Output
21
Explanation
Digits are 4, 4, 2, and 1. Product = 32. Sum = 11. Difference = 32 - 11 = 21.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.