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
Inputn = 234
Output15
Product of digits is 2 * 3 * 4 = 24, sum of digits is 2 + 3 + 4 = 9, and 24 - 9 = 15.
Example 2
Inputn = 4421
Output21
Product 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

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate