|
|
|
public class MotzkinNumber {
|
|
|
|
public static void main(String[] args) {
|
|
for(int i=0;i<=20;i++)System.out.format("%d:%d%n",i,M(i));
|
|
|
|
}
|
|
public static int M(int n) {
|
|
if(n==0 || n==1)
|
|
return 1;
|
|
int temp = 0;
|
|
for(int i = 0;i<=n-2;i++)temp+=M(i)*M(n-2-i);
|
|
return M(n-1)+temp;
|
|
}
|
|
|
|
}
|