Skip to content

Commit e120afe

Browse files
authored
Create finding catalan number
1 parent b9e640e commit e120afe

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

finding catalan number

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
long long int catalan(int n, int k)
2+
{
3+
long long int res=1;
4+
if(k > n-k)
5+
k = n-k;
6+
7+
for(int i=0;i<k;i++)
8+
{
9+
res*=(n-i);
10+
res/=(i+1);
11+
}
12+
return res;
13+
}
14+
int numTrees(int n)
15+
{
16+
unsigned long int c = catalan(2*n,n);
17+
return (c/(n+1));
18+
}

0 commit comments

Comments
 (0)