当前位置:网站首页>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;
}
}
边栏推荐
- redis秒杀案例,跟着b站尚硅谷老师学习
- Technology vane | interpretation of cloud native technology architecture maturity model
- opiodr aborting process unknown ospid (21745) as a result of ORA-609
- Pytorch损失函数总结
- 常见弱口令大全
- easyui中textbox在光标位置插入内容
- Penetration test - post penetration - Trace cleaning
- Spark Learning Notes (V) -- spark core core programming RDD conversion operator
- It's too strong. An annotation handles the data desensitization returned by the interface
- Deeply understand the underlying data structure and algorithm of MySQL index
猜你喜欢

redis秒杀案例,跟着b站尚硅谷老师学习

redis入门练习

Detailed explanation of const usage in C language

Graphic SQL, this is too vivid!

spark学习笔记(四)——sparkcore核心编程-RDD

The function and application of lpci-252 universal PCI interface can card

Customer cases | pay attention to the elderly user experience, and the transformation of bank app to adapt to aging should avoid falsehood and be practical

Quick sequencing and optimization

代码审查金字塔

Introduction to database - a brief introduction to MySQL
随机推荐
若依的环境的部署以及系统的运行
基于OpenCV的轮廓检测(1)
Customer cases | pay attention to the elderly user experience, and the transformation of bank app to adapt to aging should avoid falsehood and be practical
The application and significance of digital twins are the main role and conceptual value of electric power.
Jmeter分布式压测
Volatile keyword and its function
Introduction to database - a brief introduction to MySQL
“满五唯一”和“满二唯一”是什么?有什么不同?
Design method and test method of APP interface use case
Redis spike case, learn from Shang Silicon Valley teacher in station B
MySQL:互联网公司常用分库分表方案汇总
spark学习笔记(四)——sparkcore核心编程-RDD
Fastboot刷机
百融榕树数据分析拆解方法
快速排序及优化
索引最佳实践
Network security / penetration testing tool awvs14.9 download / tutorial / installation tutorial
$128million! IQM, a Finnish quantum computing company, was supported by the world fund
Data analysis and disassembly method of banyan tree in Bairong
DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库