Dyck path | Returns count Dyck paths in n x n grid ; Compute value of 2 nCn ; return 2 nCn / ( n + 1 ) ; Driver Code
< ? php function countDyckPaths ( $ n ) { $ res = 1 ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ res *= ( 2 * $ n - $ i ) ; $ res /= ( $ i + 1 ) ; } return $ res / ( $ n + 1 ) ; } $ n = 4 ; echo " Number ▁ of ▁ Dyck ▁ Paths ▁ is ▁ " , countDyckPaths ( $ n ) ; ? >