求阶乘结果尾部 0 的个数 Factorials and Trailing Zeroes

size_t fuck(size_t n)
{
    double index = 1.0;
    size_t result = 0;
    while (true) {
        auto count = n / static_cast<size_t>(pow(5.0, index));
        if(count == 0){
            return result;
        }
        ++index;
        result += count;
    }
}

 当然,也不是我凭空想出的,之前我一直不明白为何 25!的结果是六个 0。直到看了 这篇文章 才刚反应过来,确实我这方面是个软肋哈。更要感谢这篇文章的作者给了我启发。

原文地址:https://www.cnblogs.com/wuOverflow/p/4649741.html