text: Program to find N | Function to find n - th number in series made of 3 and 5 ; create an array of size ( n + 1 ) ; If i is odd ; Driver code
code: < ? php function printNthElement ( $ n ) { $ arr = array_fill ( 0 , ( $ n + 1 ) , NULL ) ; $ arr [ 1 ] = 3 ; $ arr [ 2 ] = 5 ; for ( $ i = 3 ; $ i <= $ n ; $ i ++ ) { if ( $ i % 2 != 0 ) $ arr [ $ i ] = $ arr [ $ i / 2 ] * 10 + 3 ; else $ arr [ $ i ] = $ arr [ ( $ i / 2 ) - 1 ] * 10 + 5 ; } return $ arr [ $ n ] ; } $ n = 6 ; echo printNthElement ( $ n ) ; ? >