So I need a way to figure out how to get 5 numbers, and when you add any 2 of them, it will result in a sum that you can only get by adding those specific two numbers.
Here's an example of what I'm talking about, but with 3 numbers:
1
3
5
1 + 3 = 4
1 + 5 = 6
3 + 5 = 8
Adding any two of those numbers will end up with a unique sum that cannot be found by adding any other pair of the numbers. I need to do this, but with 5 different numbers. And if you have a method of figuring out how to do this with any amount of numbers, sharing that would be appreciated as well. Thank you
1, 10, 100, 10000, 100000
gives you five numbers like you desire.
In general, 1, 10, 100, 1000, ..., 10^k
where k
is the number of numbers that you need.
And even more general, you can say b^0, b^1, ..., b^k
, where b >= 2
. Note that you have the special property that not only are all the pairwise sums unique, but all the subset sums are unique (just look at representations in base b
).
The set {1, 2, 5, 11, 21}
also works.
You can start with a set of two or three elements that fit that property (any addition operation on two elements from the set {1,2,5}
gives you an unique sum) and only include the next number being considered if additions of current elements and this new element also give you unique sums.
An example run-through:
Suppose our starting set S
is S={1,2,5}
. Let U
be the set of all sums between two elements in S
.
Elements in S
give us unique sums 1+2=3
, 1+5=6
, 2+5=7
, so U={3,6,7}
.
Consider adding 11
to this set. We need to check that 1+11
, 2+11
, and 5+11
all give us sums that are not seen in U
and are all unique among themselves.
1+11=12
, 2+11=13
, 5+11=17
.
Since 12
, 13
, and 17
are all unique sums among themselves, and are not found in U
, we can update S
and U
to be:
S1 = {1,2,5,11}
U1 = {3,6,7,12,13,17}
.
You can do the same procedure for 21
, and you should (hopefully) get:
S2 = {1,2,5,11,21}
U2 = {3,6,7,12,13,17,22,23,26,32}
.
If all you need is a quick set though, the solution that Jason posted is a lot faster to produce.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With