Puzzle of gold coins in the bag At the end of Probability class, our professor gave us the following puzzle:

There are 100 bags each with 100 coins, but only one of these bags has gold coins in it. The gold coin has weight of 1.01 grams and the other coins has weight of 1 gram. We are given a digital scale, but we can only use it once. How can we identify the bag of gold coins?

After about 5 minutes waiting, our professor gave us the solution (the class had ended and he didn't want to wait any longer):

Give the bags numbers from 0 through 99, then take 0 coins from the bag number 0, 1 coin from the bag number 1, 2 coins from the bag number 2, and so on until we take 99 coins from the bag number 99. Gather all the coins we have taken together and put them on the scale. Denote the weight of these coins as $W$ and the number of bag with gold coins in it as $N$, then we can identify the bag of gold coins using formula $$N=100(W-4950)$$
  For instance, if the weight of all coins gathered is $4950.25$ grams, then using the formula above the bag number 25 has the gold coins in it.

My questions are:


*

*How does the formula work? Where does it come from?

*Do we have other ways to solve this puzzle? If yes, how?

*If the digital scale is replaced by a traditional scale, the scale like symbol of libra or the scale in Shakespeare's drama: The Merchant of Venice (I don't know what is the name in English), then how do we solve this puzzle?


The total weight of coins on the digital scale is
$$W=\sum_{m=0}^{99} mw_m$$
where $w_m$ is the weight of each coin in bag number $m.$
But if the gold coins are actually in bag number $N,$
then
$$w_m = \begin{cases}
1 + 0.01 && \text{if}\ m = N, \\
1 && \text{if}\ m \neq N.
\end{cases}$$
Therefore the only term of the sum that is not equal to $m$ is the term $Nw_N,$
which is equal to $N + 0.01N.$ So
$$W=\sum_{m=0}^{99} mw_m = \left(\sum_{m=0}^{99} m\right) + 0.01N = 4950 + 0.01N.$$
Knowing $W$, we solve for $N.$
Are there other solutions? Certainly! We could choose $m+1$ coins from each bag
numbered $m$, or in fact any number of coins as long as we take a different number
of coins from each bag and know which bag contributed what number of coins.
The same calculation as before tells us how many gold coins are on the scale,
and we then deduce which bag they must have come from.
In fact you can find the bag of gold coins among up to $101$ bags this way.
That's because there are just $101$ different numbers of coins we can draw from a bag.
If any of the bags have more coins, we can solve this for more bags.
But we cannot solve the puzzle for so many bags that there would have to be
two bags that contribute the same number of coins to the weighing, because
if we found that that was the number of gold coins on the scale then we
would not know which of the two bags they came from.
Now if you have only a two-pan balance that does not give a reading, it is no longer
possible to determine where the gold coins are in one weighing.
It will take multiple weighings, as in the solutions to this problem
and this problem.
