mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			694 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			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> </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> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= n <= 10^5</code></li>
 | 
						|
</ul>
 |