[LintCode] 尾部的零

 1 class Solution {
 2  public:
 3     // param n : description of n
 4     // return: description of return 
 5     long long trailingZeros(long long n) {
 6         long long counts = 0;
 7         for(long long i = 5; n / i; i *= 5)
 8             counts += n / i;
 9         return counts;
10     }
11 };

 

posted @ 2015-06-28 16:41  jianchao-li  阅读(220)  评论(0编辑  收藏  举报