mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 15:01:40 +08:00
45 lines
1.4 KiB
HTML
45 lines
1.4 KiB
HTML
<p>You are given a positive integer <code>n</code>. Determine whether <code>n</code> is divisible by the <strong>sum </strong>of the following two values:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The <strong>digit sum</strong> of <code>n</code> (the sum of its digits).</p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>digit</strong> <strong>product</strong> of <code>n</code> (the product of its digits).</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>Return <code>true</code> if <code>n</code> is divisible by this sum; otherwise, return <code>false</code>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">n = 99</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">true</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>Since 99 is divisible by the sum (9 + 9 = 18) plus product (9 * 9 = 81) of its digits (total 99), the output is true.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">n = 23</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">false</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>Since 23 is not divisible by the sum (2 + 3 = 5) plus product (2 * 3 = 6) of its digits (total 11), the output is false.</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= n <= 10<sup>6</sup></code></li>
|
|
</ul>
|