File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -446,11 +446,43 @@ end
446446"""
447447 integer_partitions(n)
448448
449- List the partitions of the integer `n`.
449+ Generates all partitions of the integer `n` as a list of integer arrays,
450+ where each partition represents a way to write `n` as a sum of positive integers.
451+
452+ See also: [`partitions(n::Integer)`](@ref)
450453
451454!!! note
452455 The order of the resulting array is consistent with that produced by the computational
453456 discrete algebra software GAP.
457+
458+ # Examples
459+ ```jldoctest
460+ julia> integer_partitions(2)
461+ 2-element Vector{Vector{Int64}}:
462+ [1, 1]
463+ [2]
464+
465+ julia> integer_partitions(3)
466+ 3-element Vector{Vector{Int64}}:
467+ [1, 1, 1]
468+ [2, 1]
469+ [3]
470+
471+ julia> collect(partitions(3))
472+ 3-element Vector{Vector{Int64}}:
473+ [3]
474+ [2, 1]
475+ [1, 1, 1]
476+
477+ julia> integer_partitions(-1)
478+ ERROR: DomainError with -1:
479+ n must be nonnegative
480+ Stacktrace:
481+ [...]
482+ ```
483+
484+ # References
485+ - [Integer partition - Wikipedia](https://en.wikipedia.org/wiki/Integer_partition)
454486"""
455487function integer_partitions (n:: Integer )
456488 if n < 0
You can’t perform that action at this time.
0 commit comments