mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			865 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			865 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给定一个整数 <code>n</code> ,返回 <code>n!</code> 结果中尾随零的数量。</p>
 | 
						||
 | 
						||
<p>提示 <code>n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1</code></p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>n = 3
 | 
						||
<strong>输出:</strong>0
 | 
						||
<strong>解释:</strong>3! = 6 ,不含尾随 0
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>n = 5
 | 
						||
<strong>输出:</strong>1
 | 
						||
<strong>解释:</strong>5! = 120 ,有一个尾随 0
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>n = 0
 | 
						||
<strong>输出:</strong>0
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>0 <= n <= 10<sup>4</sup></code></li>
 | 
						||
</ul>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><b>进阶:</b>你可以设计并实现对数时间复杂度的算法来解决此问题吗?</p>
 |