Program to find sum of the given sequence | C # program to find the sum of the given sequence ; function to find moudulo inverse under 10 ^ 9 + 7 ; Function to find the sum of the given sequence ; Driver code
using System ; class gfg { public long MOD = 1000000007 ; public long modInv ( long x ) { long n = MOD - 2 ; long result = 1 ; while ( n > 0 ) { if ( ( n & 1 ) > 0 ) result = result * x % MOD ; x = x * x % MOD ; n = n / 2 ; } return result ; } public long getSum ( long n , long k ) { long ans = 1 ; for ( long i = n + 1 ; i > n - k ; i -- ) ans = ans * i % MOD ; ans = ans * modInv ( k + 1 ) % MOD ; return ans ; } } class geek { public static int Main ( ) { gfg g = new gfg ( ) ; long n = 3 , k = 2 ; Console . WriteLine ( g . getSum ( n , k ) ) ; return 0 ; } }