text: Getting the modular inversion for all the numbers from 2 to r with respect to m here m = 1000000007
code: for i in range ( 2 , r + 1 ) : NEW_LINE INDENT inv [ i ] = m - ( m // i ) * inv [ m % i ] % m NEW_LINE DEDENT ans = 1 NEW_LINE