Number of n | Java program To calculate Number of n - digits non - decreasing integers ; Returns factorial of n ; returns nCr ; Driver code
class GFG { static long fact ( int n ) { long res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static long nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . println ( " Number ▁ of ▁ Non - Decreasing ▁ digits : ▁ " + nCr ( n + 9 , 9 ) ) ; } }