Loop to traverse all the digits of the given set
for ( int i = 0 ; i < sz ; i ++ ) { if ( D [ i ] < ( num [ pos ] - '0' ) ) { val += calculate ( pos + 1 , 1 , D , sz , num ) ; } else if ( D [ i ] == num [ pos ] - '0' ) val += calculate ( pos + 1 , tight , D , sz , num ) ; } } else {