human
What is a code to find if nCr is divisible by the given prime and the other steps required given the following:
Find if nCr is divisible by the given prime | Function to return the highest power of p that divides n ! implementing Legendre Formula.
Return the highest power of p which divides n !.
Function that returns true if nCr is divisible by p.
Find the highest powers of p that divide n ! , r ! and ( n - r ) !.
If nCr is divisible by p.
Driver code"
Solution in Python:
assistant
#Here is code to find if nCr is divisible by the given prime and the other steps required.
 def getfactor ( n , p ) :
	pw = 0 ;
	while ( n ) :
		n //= p ;
		pw += n ;
	return pw ;
def isDivisible ( n , r , p ) :
	x1 = getfactor ( n , p ) ;
	x2 = getfactor ( r , p ) ;
	x3 = getfactor ( n - r , p ) ;
	if ( x1 > x2 + x3 ) :
		return True ;
	return False ;
if __name__ == " _ _ main _ _ " :
	n = 7 ; r = 2 ; p = 7 ;
	if ( isDivisible ( n , r , p ) ) :
		print ( " Yes " ) ;
	else :
		print ( " No " ) ;