Credit for this problem goes to TED-Ed. Thanks!

Infinite Gold

Well, you’re in a real pickle. You see, a few years ago the king decided that your life would be forfeit unless you tripled the gold coins in his treasury.

Fortunately for you, a strange little man appeared and magically performed the feat. He placed magical coins in and out of a magical bag and sang a strange rhyme: “The more gold goes in and more comes out as sure as I am me. And in again and out again and now it’s it times three.”

Incredibly, that tripled the coins and saved your life. Were you grateful? Yes. Were you desperate? Yes. Did you promise him your firstbord child in exchange for his help? Yes…

Fast forward to today. No sooner have you given birth to a beautiful baby boy, but then the little man shows up to claim his prize. You cry and beg him not to take the baby.

“My bag” he explains “increases the number of gold coins inside it in a very special way. If I take any number of coins and place them in, more will come out. And if I place those in the bag again, the total that comes out will be 3x whatever I began with.”

He takes 13 coins and places them in the bag and then removes the contents. “I’ve used the magic once, not twice” he says. “Tell me how many coins are in my hand and I’ll have mercy.”

How many coins is he holding?

Rules:

  1. The bag magically increases gold coins by a consistent set of rules. Putting in a given number of coins at any point will always produce the same result.
  2. The more gold goes in, the more comes out. In other words, putting 3 coins in will result in more coins coming out than if you put 2 coins in.
  3. If you use the magic twice, the initial number of coins will always be tripled.
  4. Gold coins always go in and come out in whole numbers. No fractions or irrational parts of coins are allowed.
  5. You need to figure out how many coins will result from the magic being applied once to 13 coins (not twice).
Solution