232k views
2 votes
Given a set of weights {1,3,9,27}, show that you can construct any number between 1 and 40. In other words, using the set above and the addition and subtraction operations, construct any integer between 1 and 40 without re-using elements. For example, 4 = 1+1+1+1 is not acceptable.

For example,
8 = 9 - 1
10 = 1 + 9

1 Answer

5 votes

Answer:

Yes

Step-by-step explanation:

One way to prove it is by trying out all the possible combinations and see if the resulting set of numbers contains all the numbers from 1 to 40. You could code a program to do it omitting unnecessary calculations like those involving -27.

Proof that it is possible:

1 = 1

2 = 3-1

3 = 3

4 = 3+1

5 = 9-3-1

6 = 9-3

7 = 9-3+1

8 = 9-1

9 = 9

10 = 9+1

11 = 9+3-1

12 = 9+3

13 = 9+3+1

14 = 27-9-3-1

15 = 27-9-3

16 = 27-9-3+1

17 = 27-9-1

18 = 27-9

19 = 27-9+1

20 = 27-9+3-1

21 = 27-9+3

22 = 27-9+3+1

23 = 27-3-1

24 = 27-3

25 = 27-3+1

26 = 27-1

27 = 27

28 = 27+1

29 = 27+3-1

30 = 27+3

31 = 27+3+1

32 = 27+9-3-1

33 = 27+9-3

34 = 27+9-3+1

35 = 27+9-1

36 = 27+9

37 = 27+9+1

38 = 27+9+3-1

39 = 27+9+3

40 = 27+9+3+1

User Evgenii Vorobei
by
6.3k points