设为首页 加入收藏

TOP

172. Factorial Trailing Zeroes
2017-10-12 17:39:25 】 浏览:3841
Tags:172. Factorial Trailing Zeroes

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

Note: Your solution should be in logarithmic time complexity.

 

 1 int trailingZeroes(int n) {
 2     if(n < 5)
 3         return 0;
 4     int k = 0;
 5     while(n)
 6     {
 7         n = n / 5;
 8         k += n;
 9     }
10     return k;
11 }

转:http://www.jianshu.com/p/211618afc695

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇冒泡排序的实现 下一篇自制编程语言crowbar(v0.1)构建解..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目