Golomb sequence | Print the first n term of Golomb Sequence ; base cases ; Finding and printing first n terms of Golomb Sequence . ; Driver Code
< ? php function printGolomb ( $ n ) { $ dp [ 1 ] = 1 ; echo $ dp [ 1 ] , " " ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) { $ dp [ $ i ] = 1 + $ dp [ $ i - $ dp [ $ dp [ $ i - 1 ] ] ] ; echo $ dp [ $ i ] , " " ; } } $ n = 9 ; printGolomb ( $ n ) ; ? >