Maximum number that can be display on Seven Segment Display using N segments | Java implementation of above approach ; Function to print maximum number that can be formed using N segments ; If n is odd ; use 3 three segment to print 7 ; remaining to print 1 ; If n is even ; print n / 2 1 s . ; Driver Code
class GFG { public static void printMaxNumber ( int n ) { if ( n % 2 != 0 ) { System . out . print ( "7" ) ; for ( int i = 0 ; i < ( n - 3 ) / 2 ; i ++ ) System . out . print ( "1" ) ; } else { for ( int i = 0 ; i < n / 2 ; i ++ ) System . out . print ( "1" ) ; } } public static void main ( String [ ] args ) { int n = 5 ; printMaxNumber ( n ) ; } }