17 lines
278 B
OCaml
17 lines
278 B
OCaml
|
let catalan n =
|
||
|
let t = Array.make (n+1) 0 in
|
||
|
t.(0) <- 1;
|
||
|
for i=1 to n do
|
||
|
for k=0 to i-1 do
|
||
|
t.(i) <- (t.(k)*t.(i-1-k)) + t.(i)
|
||
|
done
|
||
|
done;
|
||
|
t.(n);;
|
||
|
|
||
|
catalan 5;;
|
||
|
|
||
|
let rec est_triee l = match l with
|
||
|
| [] -> true
|
||
|
| [a] -> true
|
||
|
| a::(b::t) -> a<=b && est_triee b::t;;
|