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
< ? php function trailingZero ( $ x ) { $ i = 5 ; $ count = 0 ; while ( $ x > $ i ) { $ count = $ count + ( int ) ( $ x / $ i ) ; $ i = $ i * 5 ; } return $ count ; } function countProductTrailing ( $ M , $ N ) { return trailingZero ( $ N ) + trailingZero ( $ M ) ; } $ N = 67 ; $ M = 98 ; echo ( countProductTrailing ( $ N , $ M ) ) ; ? >