Function to return the highest power of p that divides n
def countFactors ( n , p ) : NEW_LINE INDENT pwr = 0 ; NEW_LINE while ( n > 0 and n % p == 0 ) : NEW_LINE INDENT n //= p ; NEW_LINE pwr += 1 ; NEW_LINE DEDENT return pwr ; NEW_LINE DEDENT