Smallest positive number made up of non | Function to find smallest positive number made up of non - repeating digits whose sum of its digits is equal to n ; No such number exists ; Stores the required answer ; Store the digit at unit 's place ; Iterate until n > digit ; Push digit at the start of res ; Decrement n by digit ; Decrement digit by 1 ; Push the remaining number as the starting digit ; Print the required number ; Driver Code ; Function Call
def result ( n ) : NEW_LINE INDENT if ( n > 45 ) : NEW_LINE INDENT print ( - 1 , end = " " ) NEW_LINE return NEW_LINE DEDENT res = " " NEW_LINE digit = 9 NEW_LINE while ( n > digit ) : NEW_LINE INDENT res = str ( digit ) + res NEW_LINE n -= digit NEW_LINE digit -= 1 NEW_LINE DEDENT if ( n > 0 ) : NEW_LINE INDENT res = str ( n ) + res NEW_LINE DEDENT print ( res ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 19 NEW_LINE result ( N ) NEW_LINE DEDENT