human
Binomial Coefficient | DP | Function to find binomial coefficient.
Getting the modular inversion for all the numbers from 2 to r with respect to m here m = 1000000007.
for 1 / ( r ! ) part.
for ( n ) * ( n - 1 ) * ( n - 2 ) * ... * ( n - r + 1 ) part.
Driver code"
Solution in Python:

Can you provide a code to binomial Coefficient and the other steps required?
assistant
#Here is code to binomial Coefficient and the other steps required.
 def binomialCoeff ( n , r ) :
	if ( r > n ) :
		return 0
	m = 1000000007
	inv = [ 0 for i in range ( r + 1 ) ]
	inv [ 0 ] = 1 ;
	if ( r + 1 >= 2 )
	inv [ 1 ] = 1 ;
	for i in range ( 2 , r + 1 ) :
		inv [ i ] = m - ( m // i ) * inv [ m % i ] % m
	ans = 1
	for i in range ( 2 , r + 1 ) :
		ans = ( ( ans % m ) * ( inv [ i ] % m ) ) % m
	for i in range ( n , n - r , - 1 ) :
		ans = ( ( ans % m ) * ( i % m ) ) % m
	return ans
n = 5
r = 2
print ( " Value ▁ of ▁ C ( " , n , " , ▁ " , r , " ) ▁ is ▁ " , binomialCoeff ( n , r ) )