Print N | function to generate n digit numbers ; if number generated ; Append 1 at the current number and reduce the remaining places by one ; If more ones than zeros , append 0 to the current number and reduce the remaining places by one ; Driver Code ; Function call
def printRec ( number , extraOnes , remainingPlaces ) : NEW_LINE INDENT if ( 0 == remainingPlaces ) : NEW_LINE INDENT print ( number , end = " ▁ " ) NEW_LINE return NEW_LINE DEDENT printRec ( number + "1" , extraOnes + 1 , remainingPlaces - 1 ) NEW_LINE if ( 0 < extraOnes ) : NEW_LINE INDENT printRec ( number + "0" , extraOnes - 1 , remainingPlaces - 1 ) NEW_LINE DEDENT DEDENT def printNums ( n ) : NEW_LINE INDENT str = " " NEW_LINE printRec ( str , 0 , n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 4 NEW_LINE printNums ( n ) NEW_LINE DEDENT