Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
nextrow[lastrow_] := Module[{output},
|
||||
output = ConstantArray[1, Length[lastrow] + 1];
|
||||
Do[
|
||||
output[[i + 1]] = lastrow[[i]] + lastrow[[i + 1]];
|
||||
, {i, 1, Length[lastrow] - 1}];
|
||||
output
|
||||
]
|
||||
pascaltriangle[size_] := NestList[nextrow, {1}, size]
|
||||
catalannumbers[length_] := Module[{output, basetriangle},
|
||||
basetriangle = pascaltriangle[2 length];
|
||||
list1 = basetriangle[[# *2 + 1, # + 1]] & /@ Range[length];
|
||||
list2 = basetriangle[[# *2 + 1, # + 2]] & /@ Range[length];
|
||||
list1 - list2
|
||||
]
|
||||
(* testing *)
|
||||
catalannumbers[15]
|
||||
Loading…
Add table
Add a link
Reference in a new issue