当前位置:网站首页>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;
}
}
边栏推荐
- Graphic SQL, this is too vivid!
- How many implementation postures of delay queue? Daily essential skills!
- 数据库使用安全策略
- Unity game, the simplest solution of privacy agreement! Just 3 lines of code! (Reprinted)
- Volatile keyword and its function
- 阶乘末尾0的数量
- “满五唯一”和“满二唯一”是什么?有什么不同?
- [common search questions] 111
- 客户端发送一条sql如何与服务器交互
- Insert pictures and videos in typera
猜你喜欢

Detailed explanation of const usage in C language

【树链剖分】2022杭电多校2 1001 Static Query on Tree

The application and significance of digital twins are the main role and conceptual value of electric power.

客户案例 | 关注老年用户体验,银行APP适老化改造要避虚就实

app端接口用例设计方法和测试方法

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

MySQL的数据库有关操作

数字孪生应用及意义对电力的主要作用,概念价值。

A new paradigm of distributed deep learning programming: Global tensor

redis秒杀案例,跟着b站尚硅谷老师学习
随机推荐
Insert pictures and videos in typera
代码审查金字塔
$128million! IQM, a Finnish quantum computing company, was supported by the world fund
Fastboot刷机
Pytorch损失函数总结
数据库概论 - 数据库的介绍
spark:计算不同分区中相同key的平均值(入门级-简单实现)
Mysql: summary of common sub database and sub table schemes of Internet companies
[regular] judgment, mobile number, ID number
spark学习笔记(六)——sparkcore核心编程-RDD行动算子
数字孪生实际应用:智慧城市项目建设解决方案
Introduction to database - a brief introduction to MySQL
be based on. NETCORE development blog project starblog - (16) some new functions (monitoring / statistics / configuration / initialization)
Volatile keyword and its function
Typescript TS basic knowledge interface, generics
typescript ts 基础知识之接口、泛型
【学习笔记之菜Dog学C】字符串+内存函数
The function and application of lpci-252 universal PCI interface can card
百融榕树数据模型
Data analysis and disassembly method of banyan tree in Bairong