The nth Catalan number can be calculated using either recursion or dynamic programming. Here's how to do it in Swift using recursion:

`main.swift201 chars12 lines`

Here's how to do the same thing using dynamic programming, which is more efficient:

`main.swift258 chars12 lines`

Both functions take an integer `n`

as input and return the nth Catalan number.

find the nth catalan number in swift

get distinct permutations of a set in swift

how to get distinct permutations of a set in swift

how to get all subsets of a set in swift

how to get distinct combinations of a set in swift

how to get all permutations of a set in swift

how to get the cartesian product of two sets in swift

find the average of all elements in an array in swift

find the sum of all elements in an array in swift

how to get all combinations of a set in swift

gistlibby LogSnag