Leetcode 172 Factorial Trailing Zeroes
给定一个数n 求出n!的末尾0的个数。
n!的末尾0产生的原因其实是n! = x * 10^m
如果能将n!是2和5相乘,那么只要统计n!约数5的个数.
class Solution {
public:
int trailingZeroes(int n) {
int ans = ;
for( ;n; ans+=n/,n/=);
return ans;
}
};
Leetcode 172 Factorial Trailing Zeroes的更多相关文章
- [LeetCode] 172. Factorial Trailing Zeroes 求阶乘末尾零的个数
Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...
- LeetCode 172. Factorial Trailing Zeroes (阶乘末尾零的数量)
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
- Java 计算N阶乘末尾0的个数-LeetCode 172 Factorial Trailing Zeroes
题目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in ...
- ✡ leetcode 172. Factorial Trailing Zeroes 阶乘中的结尾0个数--------- java
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
- Java for LeetCode 172 Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
- Java [Leetcode 172]Factorial Trailing Zeroes
题目描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be ...
- leetcode 172. Factorial Trailing Zeroes(阶乘的末尾有多少个0)
数字的末尾为0实际上就是乘以了10,20.30.40其实本质上都是10,只不过是10的倍数.10只能通过2*5来获得,但是2的个数众多,用作判断不准确. 以20的阶乘为例子,造成末尾为0的数字其实就是 ...
- [LeetCode]172. Factorial Trailing Zeroes阶乘尾随0的个数
所有的0都是有2和45相乘得'到的,而在1-n中,2的个数是比5多的,所以找5的个数就行 但是不要忘了25中包含两个5,125中包含3个5,以此类推 所以在找完1-n中先找5,再找25,再找125.. ...
- LeetCode Day4——Factorial Trailing Zeroes
/* * Problem 172: Factorial Trailing Zeroes * Given an integer n, return the number of trailing zero ...
随机推荐
- Selenium2+python自动化19-单选框和复选框(radiobox、checkbox)
本篇主要介绍单选框和复选框的操作 一.认识单选框和复选框 1.先认清楚单选框和复选框长什么样 2.各位小伙伴看清楚哦,上面的单选框是圆的:下图复选框是方的,这个是业界的标准,要是开发小伙伴把图标弄错了 ...
- python 文件拷贝
用python实现了一个小型的自动发版本的工具.这个“自动发版本”有点虚, 只是简单地把debug 目录下的配置文件复制到指定目录,把Release下的生成文件复制到同一指定,过滤掉不需要的文件夹(. ...
- java io学习之File类
1.先看下四个静态变量 static String pathSeparator The system-dependent path-separator character, represented a ...
- Where art thou
function where(collection, source) { var arr = []; // What's in a name? var keys = Object.keys(sourc ...
- 2015/09/09夜晚js继续学习
单词:标量(scalar)数组(array)元素(element)填充(populating)下标(index) 向数组中添加元素的操作称之填充.在填充数组时,不仅需要给出新元素的值,还需要给新元素在 ...
- 用过的一个jquery插件实现转盘效果还不错手机兼容
(function($) {var supportedCSS,styles=document.getElementsByTagName("head")[0].style,toChe ...
- NDK开发之引用(局部引用,全局引用,虚全局引用)
1.先引出我遇到的一个问题(我觉得先写问题,这样印象更深刻一点): Android Java层在调用本地jni代码的时候, 会维护一个局部引用表(最大长度是512), 一般jni函数调用结束后, jv ...
- lua中for循环的四种遍历方式
lua中for的四种遍历方式区别 table.maxn 取最大的整数key #table 从1开始的顺序整数最大值,如1,2,3,6 #table == 3 key,value pairs 取每一 ...
- dropbear
生成ssh连接所需要的公钥,如下: /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key (dss加密,长度默认 ...
- 远程桌面Default.rdp 中各个参数的含义(转)
存储在 Default.rdp 文件中的设置 默认情况下,将在“我的文档”文件夹中创建 Default.rdp 文件.以下 RDP 设置存储在 Desktop.rdp 文件中: desktopwidt ...