text: Program to find the N | Javascript program to find n - th number containing only 3 and 5. ; If n is odd , append 3 and move to parent ; If n is even , append 5 and move to parent ; Reverse res and return . ; Driver code
code: function reverseString ( str ) { return str . split ( " " ) . reverse ( ) . join ( " " ) ; } function findNthNo ( n ) { let res = " " ; while ( n >= 1 ) { if ( ( n & 1 ) == 1 ) { res = res + " " ; n = ( n - 1 ) / 2 ; } else { res = res + " " ; n = ( n - 2 ) / 2 ; } } sb = ( res ) ; sb = reverseString ( sb ) ; return ( sb ) ; } let n = 5 ; document . write ( findNthNo ( n ) ) ;