Let bi be the number of marbles in bag i.

Then write out the equations:

b1+b2+b3+b4+b5=100

b1+b2...............=51

.....b2+b3..........=42

..........b3+b4.....=35

...............b4+b5=31

Now subtract the second of these from the first to get:

b3+b4+b5=100-51=49

Now subtract the foruth from this to get:

b5=49-35=14

Now back substitution of this into the fifth to second equations to will

give the values for the remaining bags.

RonL