n | Java 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
class GFG { static final int max = 100000 ; static int baseconversion ( int arr [ ] , int num , int base ) { int i = 0 , rem , j ; if ( num == 0 ) { return 0 ; } while ( num > 0 ) { rem = num % base ; arr [ i ++ ] = rem ; num /= base ; } return i ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ max ] ; int n = 10 ; int size = baseconversion ( arr , n - 1 , 6 ) ; if ( size == 0 ) System . out . print ( size ) ; for ( int i = size - 1 ; i >= 0 ; i -- ) { System . out . print ( arr [ i ] ) ; } } }