[LintCode]末尾のゼロ

1795 ワード

 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 };