## find a list of integers for a checksum

Question

I would need a list of *n* positive integers **L** that has this properties:

- for each possible subset
**S**of**L**, if I sum all items of**S**, this sum is not in**L** - for each possible subset
**S**of**L**, if I sum all items of**S**, this sum is unique (each subset can be identified by his sum)

Working example 1:

```
n = 4
L = [1, 5, 7, 9]
check:
1+5 = 6 ok
5+7 = 12 ok
7+9 = 16 ok
9+1 = 10 ok
1+7 = 8 ok
5+9 = 14 ok
1+5+7 = 13 ok
5+7+9 = 21 ok
1+5+9 = 15 ok
1+7+9 = 17 ok
1+5+7+9 = 22 ok
All sums are unique -> L is OK for n = 4
```

Show source

## Answers ( 1 )

As an easy to construct sequence, I suggest using

power series, e.g.Take, for instance,

`2`

: neither power of`2`

is a sum of other`2`

powers; given a`sum`

(number) you can easily find out the subset by converting`sum`

into binary representation:In general case, a simple

greedy algorithmwill do: given a`sum`

subtract the largest item less or equal to the`sum`

; continue subtracting up to zero: