n的阶乘末尾有多少个0,阶乘末尾,请写一段程序计算n的阶乘


请写一段程序计算n的阶乘末尾有多少个0,例如5! = 120 末尾有1个0,10!= 3628800末尾有2个0。

import mathdef fact_tail_zero_count(x):    return sum( int(x/5**(i+1)) for i in range( int(math.log(x,5)) ))print fact_tail_zero_count(100)print fact_tail_zero_count(10**8)#该片段来自于http://byrx.net

评论关闭