Python:
import itertools
array = [1, 2, 3]
arr2 = []
for i in range(len(array)):
for a in itertools.product(array, repeat=i):
arr2.append(sum(a))
print(*set(arr2))
Python:
import itertools
array = [1, 2, 3]
arr2 = []
for i in range(len(array)):
for a in itertools.product(array, repeat=i):
arr2.append(sum(a))
print(*set(arr2))