We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd88b64 commit c0f5dbcCopy full SHA for c0f5dbc
src/Catalan.jl
@@ -1,4 +1,5 @@
1
module Catalan
2
+
3
using Polynomial
4
5
export bell,
@@ -15,7 +16,8 @@ export bell,
15
16
multinomial,
17
primorial,
18
stirlings1,
- subfactorial
19
+ subfactorial,
20
+ partitions
21
22
include("youngdiagrams.jl")
23
@@ -149,4 +151,22 @@ function stirlings1(n::Integer, k::Integer)
149
151
p[n - k + 1]
150
152
end
153
154
+# Lists the partitions of the number n, the order is consistent with GAP
155
+function partitions(n)
156
+ if n == 1
157
+ return Vector{Int}[[1]]
158
+ end
159
160
+ list = Vector{Int}[]
161
162
+ for p in partitions(n-1)
163
+ push!(list, [p, 1])
164
+ if length(p) == 1 || p[end] < p[end-1]
165
+ push!(list, [p[1:end-1], p[end]+1])
166
167
168
169
+ list
170
+end
171
172
0 commit comments