Golomb sequence | Return the nth element of Golomb sequence ; base case ; Recursive Step ; Print the first n term of Golomb Sequence ; Finding first n terms of Golomb Sequence . ; Driver Code
< ? php function findGolomb ( $ n ) { if ( $ n == 1 ) return 1 ; return 1 + findGolomb ( $ n - findGolomb ( findGolomb ( $ n - 1 ) ) ) ; } function printGolomb ( $ n ) { for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) echo findGolomb ( $ i ) , " ▁ " ; } $ n = 9 ; printGolomb ( $ n ) ; ? >