Given an integer n, return the number of trailing zeroes in n!.

Note: Your solution should be in logarithmic time complexity.

思路:编程之美里有,就是找因子5的个数。

int trailingZeroes(int n) {
int ans = ;
while(n > )
{
ans += n / ;
n /= ;
}
return ans;
}

【leetcode】Factorial Trailing Zeroes(easy)的更多相关文章

  1. 【leetcode】Factorial Trailing Zeroes

    题目描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be ...

  2. 【leetcode】Set Matrix Zeroes(middle)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 思路:不能用 ...

  3. 【leetcode】Reverse Linked List(easy)

    Reverse a singly linked list. 思路:没啥好说的.秒... ListNode* reverseList(ListNode* head) { ListNode * rList ...

  4. 【leetcode】Count and Say (easy)

    The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...

  5. 【leetcode】Longest Common Prefix (easy)

    Write a function to find the longest common prefix string amongst an array of strings. 思路:找最长公共前缀 常规 ...

  6. 【LeetCode】数组--合并区间(56)

    写在前面   老粉丝可能知道现阶段的LeetCode刷题将按照某一个特定的专题进行,之前的[贪心算法]已经结束,虽然只有三个题却包含了简单,中等,困难这三个维度,今天介绍的是第二个专题[数组] 数组( ...

  7. LeetCode 172. Factorial Trailing Zeroes (阶乘末尾零的数量)

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  8. 【leetcode】Number of Islands(middle)

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  9. 【LeetCode】Agorithms 题集(一)

    Single Number 题目 Given an array of integers, every element appears twice except for one. Find that s ...

随机推荐

  1. Notepad++的插件

    1.4. Notepad++中常用的插件 1.4.1. 插件管理器: Plugin Manager 插件功能:此插件可以帮你管理插件,包括查看当前已经安装的插件有哪些,以及自动帮你下载相应的插件. 插 ...

  2. codevs2171 棋盘覆盖

    题目描述 Description 给出一张n*n(n<=100)的国际象棋棋盘,其中被删除了一些点,问可以使用多少1*2的多米诺骨牌进行掩盖. 输入描述 Input Description 第一 ...

  3. 解析某些特殊格式XML文件时,获取不到根节点问题

    还是在语音识别这块.在读取本地的SRGS的XML后,无法获取到根节点<grammar>. 下面是SRGS.XML文件(只给出了根节点) <?xml version="1.0 ...

  4. nyoj 613 免费馅饼 广搜

    免费馅饼 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy ...

  5. <a>标签跳转传值。

    <a href="public_html/app/Tpl/song_1/inc/{url r="deal#support" p="id=$deal_inf ...

  6. oracle数据表创建分区与查询

    场景: 遇到1亿数据量的数据需要根据用户名做些数据统计分析,想直接做些聚合计算基本没可能,于是打算先根据日期按照年月创建分区,然后对各个分区分别进行统计,最后汇总结果. 有两种方法,分别是手工设置分区 ...

  7. 解决Ckeditor编辑器不显示html实体,自动过滤html的问题

    Ckeditor 4.5.4,在编辑的时候,使用源码编辑,当保存内容包含Javascript.Style标签的时候,数据库中有Javascript.Style标签,输入到页面也可以执行,但是我再次编辑 ...

  8. 使用APPCAN开发移动应用APP心得

    要想使用APPCAN开发移动应用,首先要弄明白什么是APPCAN,APPCAN都具有哪些功能. 1.什么是APPCAN? APPCAN是正益无线公司开发的一套Hybrid混合应用开发平台(AppCan ...

  9. ionic中返回上一页

    .controller('NewsCtrl', ["$scope", "$ionicHistory", "$http","$tim ...

  10. angularjs表达式中的HTML内容,如何不转义,直接表现为html元素

    在模板中直接: 在ionic中直接使用: <p class="contentwen" ng-bind-html="detial.content">& ...