Program to calculate value of nCr | CPP program To calculate The Value Of nCr ; Returns factorial of n ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int fact ( int n ) ; int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } int main ( ) { int n = 5 , r = 3 ; cout << nCr ( n , r ) ; return 0 ; }