Count of N | Java implementation of the approach ; Function to return the factorial of n ; Function to return the count of n - digit numbers with all distinct digits ; Driver code
class GFG { static int factorial ( int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } static int countNum ( int n ) { if ( n > 10 ) return 0 ; return ( 9 * factorial ( 9 ) / factorial ( 10 - n ) ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( countNum ( n ) ) ; } }