Using Combinatorics.jl (and collect-free after @DNF’s advice):
using Combinatorics
function sum_combinations(N)
list = Vector{Int64}[]
for i in 2:N
for x in combinations(1:N,i)
if sum(x) == N
push!(list, x)
end
end
end
return list
end
julia> sum_combinations(7)
4-element Vector{Vector{Int64}}:
[1, 6]
[2, 5]
[3, 4]
[1, 2, 4]