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
< ? php function getValue ( $ n ) { $ i = 0 ; $ k = 1 ; while ( $ i < $ n ) { $ i = $ i + $ k ; $ k = $ k * 2 ; } return ( int ) $ k / 2 ; } $ n = 9 ; echo getValue ( $ n ) , " STRNEWLINE " ; $ n = 1025 ; echo getValue ( $ n ) , " STRNEWLINE " ; ? >