Python version 2.7.6
I wrote an iterative function that computes the number of trailing zeros expected with a particular factorial. I then tried to rewrite it as a recursive function. This is the recursive result:
def f_FactorialTailZeros(v_Num, v_Result = 0):
if v_Num < 5:
return v_Num
v_Result = v_Result + f_FactorialTailZeros(v_Num // 5, v_Num // 5)
return v_Result
print(f_FactorialTailZeros(30)) ## 7
print(f_FactorialTailZeros(70)) ## 16
It works, but, for the sake of learning, is there a better way?