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