mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
32 lines
735 B
HTML
32 lines
735 B
HTML
<p>给你一个整数 <code>n</code>,请你帮忙计算并返回该整数「各位数字之积」与「各位数字之和」的差。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 234
|
||
<strong>输出:</strong>15
|
||
<strong>解释:</strong>
|
||
各位数之积 = 2 * 3 * 4 = 24
|
||
各位数之和 = 2 + 3 + 4 = 9
|
||
结果 = 24 - 9 = 15
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 4421
|
||
<strong>输出:</strong>21
|
||
<strong>解释:
|
||
</strong>各位数之积 = 4 * 4 * 2 * 1 = 32
|
||
各位数之和 = 4 + 4 + 2 + 1 = 11
|
||
结果 = 32 - 11 = 21
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= n <= 10^5</code></li>
|
||
</ul>
|