I am learning Mathematica because I love it. I also love solving puzzles so I think it would be a nice way to learn Mathematica through puzzles. This is the second puzzle in a series I intend to solve. The first puzzle is here.
A shopkeeper has five weights to weigh things and he can weigh anything from 1 to 121 accurately (integers only) can. How do you write a program that finds those weights?
Example: The shopkeeper can weigh up to four kilos with a one-kilo weight and a three-kilo weight. If he'd put the one-kilo weight and the three-kilo weight on different sides of the scale, he could measure two kilos worth of goods. If he'd put both of the weights on the same side he can measure four kilos worth of goods.
The name of the puzzle is a pun, not a good one though as I primarily intended the shopkeeper to weight 40KG only.
Question was inspired by this question: How do I generate a set of n-tuples containing integral solutions to a linear equation provided certain constraints?

Well, I want as many syntax as there are (unless they are too many, in that case the popular ones only) to solve such questions. 1> Brute force and second the algorithm proposed in the -[Link]puzzle.stackexchange.com.
That is only because I want to Learn Mathematica.
– Jawad_Mansoor Feb 26 '17 at 12:14Okay, let me write the algorithm for you just to show you that I understand how it works.
1,3 1,3,9 1,3,9,27 1,3,9,27,81 1,3,9,27,81...
These all are multiple of 3 and will yield
4 13 40 81
and so on
That is how I did it on paper but now I want to learn a formula, syntax, program or something that uses brute force (which I call iteration) to get the answer by going through all possible combinations of numbers from 1 to 30 or 40. All positive integers.
– Jawad_Mansoor Feb 26 '17 at 12:48