Subtract the Product and Sum of Digits of an Integer

Easy

Topics
Math

Given an integer n, return the product of its digits minus the sum of its digits.

Example 1

Input:  n = 234
Output: 15
Explanation: product = 24, sum = 9, 24 - 9 = 15.

Example 2

Input:  n = 4421
Output: 21

Constraints

  • 1 <= n <= 10^5
Run ⌘' · Submit ⌘⏎