Are You a Math Genius?
Using weights of 1, 3, and 9 grams, any number of grams from 0 to 13 can be measured. In the animation below, all 14 possible weights are shown in a loop, with only a single ternary weight added or removed at each step.

If a weight of 27 grams is added, any number of grams from 0 to 40 can be measured. Is there a loop through all 41 values, with only a single ternary weight added or removed at each step?
Ternary weighing
Wolfram SpikeyPuzzles provided by Wolfram Research, Makers of Mathematica