Count of N | Function to return the factorial of n ; Function to return the count of n - digit numbers with all distinct digits ; Driver code
function factorial ( n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } function countNum ( n ) { if ( n > 10 ) return 0 ; return ( 9 * factorial ( 9 ) / factorial ( 10 - n ) ) ; } var n = 3 ; document . write ( countNum ( n ) ) ;