Question: Draw a flow chart and write a Matlab program to solve the game described below. The Stick Game 1) 100 children stand in a line,

Draw a flow chart and write a Matlab program to solve the game described below.
The Stick Game
1) 100 children stand in a line, and the first child has a basket full of sticks. None of the children has a stick to start with.
2) Starting with the first child, each child takes a turn as runner going down the line with the basket of sticks. The runner goes only down the line, starting with their own position.
3) The runner stops at every child (including themselves) whose positions is a multiple of their own position. So child #5 stops at child 5 10 15 20 etc.
4) When the runner stops at a child, they check whether the child has a stick or not.
* if the child has a stick, the runner takes it away and puts it in the basket.
* if the child has no stick, the runner gives them a stick from them basket.
Who has a stick at the end of the game? Print out the numbers of the children that have sticks at the end. That is, if every 10th child ends up with a stick, then print:
10 20 30 40 50 60 70 80 90 100
Hints:
* Make an array stick(1:100) to contain the result. stick(c)=0 means child c has no stick. stick(c)=1 means child c has a stick. So, what is the initial values of stick? What are possible values of stick?
* You can check if the child is a multiple of the runner using the modulus function:
mod(c, r) = 0 if c is a multiple of r and the runner stops
mod(c, r) ~= 0 otherwise (it's the remainder for c / r) and the runner does not stop
**answer is the perfect squares. not sure how to set up the script

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!