Program for nth Catalan Number | A recursive function to find nth catalan number ; Base case ; catalan ( n ) is sum of catalan ( i ) * catalan ( n - i - 1 ) ; Driver Code
< ? php function catalan ( $ n ) { if ( $ n <= 1 ) return 1 ; $ res = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ res += catalan ( $ i ) * catalan ( $ n - $ i - 1 ) ; return $ res ; } for ( $ i = 0 ; $ i < 10 ; $ i ++ ) echo catalan ( $ i ) , " ▁ " ; ? >