Maximum number on 7 | Function to find the maximum number that can be displayed using the N segments ; Condition to check base case ; Condition to check if the number is even ; Condition to check if the number is odd ; Driver Code
def segments ( n ) : NEW_LINE INDENT if ( n == 1 or n == 0 ) : NEW_LINE INDENT return ; NEW_LINE DEDENT if ( n % 2 == 0 ) : NEW_LINE INDENT print ( "1" , end = " " ) ; NEW_LINE segments ( n - 2 ) ; NEW_LINE DEDENT elif ( n % 2 == 1 ) : NEW_LINE INDENT print ( "7" , end = " " ) ; NEW_LINE segments ( n - 3 ) ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 11 ; NEW_LINE segments ( n ) ; NEW_LINE DEDENT