Trailing number of 0 s in product of two factorials | Returns number of zeros in factorial n ; dividing x by powers of 5 and update count ; Returns count of trailing zeros in M ! x N ! ; Driver Code
function trailingZero ( x ) { let i = 5 ; let count = 0 ; while ( x > i ) { count = count + parseInt ( x / i ) ; i = i * 5 ; } return count ; } function countProductTrailing ( M , N ) { return trailingZero ( N ) + trailingZero ( M ) ; } let N = 67 ; let M = 98 ; document . write ( countProductTrailing ( N , M ) ) ;