当前位置:网站首页>Number of 0 at the end of factorial
Number of 0 at the end of factorial
2022-07-27 03:38:00 【Swarford】

Ideas :
The problem is not to calculate n! The result of factorial , But there are a few at the end of the factorial result 0 !


Java Realization :
public class Solution {
public long thenumberof0 (long n) {
// The result is 0 The number of is only related to 2 And 5 The number of is related to ,
// every time 2*5 Can produce a 0. because 2 The number of must be greater than 5 The number of ,
// So just pay attention 5 That's enough
if(n==0){
return 0;
}
long r=0;
long i=5;
while(i<=n){
r=r+n/i;// use n Divide 5、5^2、5^3
i=i*5;
}
return r;
}
}
边栏推荐
- [1206. Design skip table]
- Spark Learning Notes (IV) -- spark core programming RDD
- Practical application of digital twins: smart city project construction solution
- MySQL underlying data structure
- [learning notes, dog learning C] string + memory function
- [flask] the server obtains the request header information of the client
- LPCI-252通用型PCI接口CAN卡的功能和应用介绍
- 基于OpenCV的轮廓检测(1)
- 阿里 Seata 新版本终于解决了 TCC 模式的幂等、悬挂和空回滚问题
- [flask] the server obtains the file requested by the client
猜你喜欢

mysql底层数据结构

mysql出现不存在错误

spark:地区广告点击量排行统计(小案例)

Code review pyramid

Quick sequencing and optimization

Practice of online problem feedback module (XV): realize the function of online updating feedback status

快速排序及优化
![[1206. Design skip table]](/img/a9/ca45c9fedd6e48387821bdc7ec625c.png)
[1206. Design skip table]

基于OpenCV的轮廓检测(1)

30 minutes to thoroughly understand the synchronized lock upgrade process
随机推荐
Unity game, the simplest solution of privacy agreement! Just 3 lines of code! (Reprinted)
Jmeter分布式压测
Byte side: can TCP and UDP use the same port?
spark学习笔记(五)——sparkcore核心编程-RDD转换算子
Design method and test method of APP interface use case
[understanding of opportunity -52]: the depth of communication varies from person to person
若依的环境的部署以及系统的运行
Sqlserver select * can you exclude a field
shell awk
Code review pyramid
Take you to know what Web3.0 is
快速排序及优化
Csu18m91 is used as the master controller of the intelligent scale scheme
Add support for @data add-on in idea
If the detailed explanation is generated according to the frame code
数据库使用安全策略
Spark: calculate the average value of the same key in different partitions (entry level - simple implementation)
Explain工具实际操作
flask_restful中reqparse解析器继承
“满五唯一”和“满二唯一”是什么?有什么不同?