text: Find nth Term of the Series 1 2 2 4 4 4 4 8 8 8 8 8 8 8 8 ... | Function that will return nth term ; Get n ; Get the value ; Get n ; Get the value
code: function getValue ( n ) { let i = 0 , k = 1 ; while ( i < n ) { i = i + k ; k = k * 2 ; } return parseInt ( k / 2 ) ; } let n = 9 ; document . write ( getValue ( n ) + " " ) ; n = 1025 ; document . write ( getValue ( n ) + " " ) ;