1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode/problem/subtract-the-product-and-sum-of-digits-of-an-integer.html
2022-03-29 12:55:24 +08:00

31 lines
694 B
HTML

Given an integer number <code>n</code>, return the difference between the product of its digits and the sum of its digits.
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> n = 234
<strong>Output:</strong> 15
<b>Explanation:</b>
Product of digits = 2 * 3 * 4 = 24
Sum of digits = 2 + 3 + 4 = 9
Result = 24 - 9 = 15
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> n = 4421
<strong>Output:</strong> 21
<b>Explanation:
</b>Product of digits = 4 * 4 * 2 * 1 = 32
Sum of digits = 4 + 4 + 2 + 1 = 11
Result = 32 - 11 = 21
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10^5</code></li>
</ul>