n | Python code to find nth number with digits 0 , 1 , 2 , 3 , 4 , 5 ; function to convert num to base 6 ; Driver code ; initialize an array to 0 ; function calling to convert number n to base 6 ; if size is zero then return zero
max = 100000 ; NEW_LINE def baseconversion ( arr , num , base ) : NEW_LINE INDENT i = 0 ; NEW_LINE if ( num == 0 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT while ( num > 0 ) : NEW_LINE INDENT rem = num % base ; NEW_LINE i = i + 1 ; NEW_LINE arr [ i ] = rem ; NEW_LINE num = num // base ; NEW_LINE DEDENT return i ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 0 for i in range ( max ) ] ; NEW_LINE n = 10 ; NEW_LINE size = baseconversion ( arr , n - 1 , 6 ) ; NEW_LINE if ( size == 0 ) : NEW_LINE INDENT print ( size ) ; NEW_LINE DEDENT for i in range ( size , 0 , - 1 ) : NEW_LINE INDENT print ( arr [ i ] , end = " " ) ; NEW_LINE DEDENT DEDENT