Generate k digit numbers with digits in strictly increasing order | number -- > Current value of number . x -- > Current digit to be considered k -- > Remaining number of digits ; Try all possible greater digits ; Generates all well ordered numbers of length k . ; Driver Code
function printWellOrdered ( number , x , k ) { if ( k == 0 ) { document . write ( number + " " ) ; return ; } for ( let i = ( x + 1 ) ; i < 10 ; i ++ ) printWellOrdered ( number * 10 + i , i , k - 1 ) ; } function generateWellOrdered ( k ) { printWellOrdered ( 0 , 0 , k ) ; } let k = 3 ; generateWellOrdered ( k ) ;