# The Dragon's Wrath

**Computer Science**Level 4

"Every one of you, brand your skin with a different number from \(1\) to \(10000\). Then stand in a circle in ascending order of your numbers. I will start counting from number \(1\) and devour every \(7{th}\) person. I will keep doing this, till there is just one of you left. And that person will be spared."

The people recognized the end, the numbers were permanent, branded with the fire of the dragon herself. They decide to assign numbers through a lottery. The mayor, being the world's last remaining mathematician, rigs the lottery, and ensures that he gets the number that would guarantee his survival.

On the fateful day, the dragon appears. She starts counting. And when she reaches the \(7{th}\) person, she snatches him up with her powerful claws and puts him in a nearby cage. The people are confused, then they realize that the dragon is putting all her food in the cage. One-by-one each person is picked up and put into the cage. In the end, the mayor remains. The dragon gives him a twisted grin, and as soon as the truth dawns on him, she snaps him up.

Everyone was terrified. The dragon had not kept her word. As they remained petrified in their fear, the dragon roared:

"The rules have changed! Now all of you come stand in a circle again, in ascending order of the number on your skin. We will then continue. I will start counting from the lowest number and put every \(7^{th}\) person in the cage. The person who will remain after the rest of you are in the cage will be eaten. You will then be let out of the cage, and we will repeat this, till only one of you is left"

The people comply. Many hours later, the dragon leaves. One last person remains. Light catches his hand, revealing the number which was etched upon his skin. What is this number?

**Note:**

As an example, consider the case when there are \(5\) people and the dragon puts every \(2^{nd}\) person in the cage:

\(1,2,3,4,5\): 2 in cage,4 in cage,1 in cage,5 in cage, 3 dies

\(1,2,4,5\): 2 in cage,5 in cage,4 in cage, 1 dies

\(2,4,5\): 4 in cage, 2 in cage, 5 dies

\(2,4\):4 in cage, 2 dies

\(4\) survives.

**Your answer seems reasonable.**Find out if you're right!

**That seems reasonable.**Find out if you're right!

Already have an account? Log in here.