Getting the modular inversion for all the numbers from 2 to r with respect to m here m = 1000000007
for ( let i = 2 ; i <= r ; i ++ ) { inv [ i ] = m - Math . floor ( m / i ) * inv [ m % i ] % m ; } let ans = 1 ;