def fac_multiplicity(n, p):
 if (p > n):
  return 0
 if (p > (n // 2)):
  return 1
 (q, m) = (n, 0)
 while (q >= p):
  q //= p
  m += q
 return m

def fac_multiplicity ( n , p ) : if ( p > n ) : return 0 if ( p > ( n // 2 ) ) : return 1 ( q , m ) = ( n , 0 ) while ( q >= p ) : q //= p m += q return m
return the power of the prime number p in the factorization of n! .