Number of n | CPP program To calculate Number of n - digits non - decreasing integers Contributed by Parishrut Kushwaha ; Returns factorial of n ; returns nCr ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long int fact ( int n ) { long long int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } long long int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } int main ( ) { int n = 2 ; cout << " Number ▁ of ▁ Non - Decreasing ▁ digits : ▁ " << nCr ( n + 9 , 9 ) ; return 0 ; }