upload MoztzkinNumber.java
This commit is contained in:
parent
43dea6e6e5
commit
bfd2e95a10
Binary file not shown.
|
@ -0,0 +1,16 @@
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue