Largest and Smallest N | Java program to find the largest and smallest N - digit numbers in Hexa - Decimal Number System ; Function to return the largest N - digit number in Hexa - Decimal Number System ; Append ' F ' N times ; Function to return the smallest N - digit number in Hexa - Decimal Number System ; Append '0' ( N - 1 ) times to 1 ; Function to print the largest and smallest N - digit Hexa - Decimal number ; Driver code
class GFG { static String findLargest ( int N ) { String largest = " " ; for ( int i = 0 ; i < N ; i ++ ) largest += ' F ' ; return largest ; } static String findSmallest ( int N ) { String smallest = "1" ; for ( int i = 0 ; i < N - 1 ; i ++ ) smallest += '0' ; return smallest ; } static void print ( int largest ) { System . out . println ( " Largest : ▁ " + findLargest ( largest ) ) ; System . out . println ( " Smallest : ▁ " + findSmallest ( largest ) ) ; } public static void main ( String [ ] args ) { int N = 4 ; print ( N ) ; } }