# Functions and Algorithms Part D: Number Games (35 minutes)

## Session 3, Part D

Here’s a number game:

• Pick a number
• Subtract 4
• Finally, multiply by 3

Note 5

Problem D1

Draw a picture of this algorithm and use your picture to answer the following questions:

1. If you pick 3, what will your final number be?
2. If you pick 5, what will your final number be?
3. If you pick 12, what will your final number be?
4. If you pick 38, what will your final number be?
5. If you pick n, what will your final number be?

Tip: After the first step, the result is n + 3.

6. If Mary’s final result is 48, what number did she pick?Tip: You will have to undo the algorithm for this and for D1(g).

7. If Joe’s final result is 30, what number did he pick?

Problem D2

Build an algorithm that lets you find the number someone picked in Problem D1 if you know his or her final result. Try it out.

Problem D3

Here’s another number game:

• Pick a number
• Subtract 4
• Finally, multiply by 3

Use the algorithm above to answer these questions:

1. If you pick 3, what will your final number be?
2. If you pick 5, what will your final number be?
3. If you pick 12, what will your final number be?
4. If you pick 38, what will your final number be?
5. If you pick n, what will your final number be?
Tip: What would you use to represent “your original number”?
6. If Mary’s final result is 48, what number did she pick?
Tip: This is more difficult than the seemingly identical question in Problem D1.
Why? What can be done about it? Does your work in D3(e) help?
7. If Joe’s final result is 30, what number did he pick?

Problem D4

Try to draw a picture of the algorithm in Problem D3. How is it different from the algorithm in Problem D1?

Problem D5

Here’s another number game:

• Pick a number
• Multiply by 3
• Multiply by 2
• Subtract 6 times your original number
• Finally, divide by 2

Use the algorithm above to answer these questions:

1. If you pick 3, what will your final number be?
2. If you pick 5, what will your final number be?
3. If you pick 12, what will your final number be?
4. If you pick 38, what will your final number be?
5. If you pick n, what will your final number be? Can you explain why?
6. If Nancy’s final result is 7, what number did she pick?

Problem D6

What strategies did you use on Problems D3(f) and D3(g)? Why are these different from the strategies used in Problems D1(f) and D1(g)?

Problem D7

Describe another number game that has the same kind of outputs as the game of Problem D5.

### Notes

Note 5

Groups: Work on Problems D1-D7 and discuss what everyone finds.

The problem with the algorithm in Problem D3 is the step “add your original number.” It’s not clear how to model that with machines. Even if we are able to adapt the machine metaphor to work, we can’t “undo” that step of the process.

Consider going through a symbolic representation of the algorithm to see that it does not share this weakness with the machine, because you can combine terms, essentially creating an equivalent algorithm that you can undo:

[(n + 3) x 2 + n – 4] x 3 = (3n + 6 – 4) x 3

(This is just one of many equivalent algorithms.)

### Solutions

Problem D1

1. If you pick 3, the final number will be 24.
2. Picking 5 gives a final number of 36.
3. Picking 12 gives 78
4. Picking 38 gives 234.
5. Picking n gives 6n + 6 [n >> n + 3 >> 2n + 6 >> 2n + 2 >> 6n + 6].
6. Mary’s original number is 7. Solving 6n + 6 = 48 gives this, or you could run 48 through the algorithm in reverse.
7. Joe started with 4.

Problem D2

This algorithm would undo the steps of the original by using inverse operations taken in reverse order. That would be:

• Pick a number
• Divide it by 3
• Cut it in half
• Subtract 3

You should find that this algorithm undoes the one in Problem D1. Inverse algorithms like this are frequently incorporated in mathematical magic tricks.

Problem D3

 a. The final number will be 33. b. The final number will be 51 c. The final number will be 114 d. The final number will be 348. e. The final number will be 9n + 6 [n >> n + 3 >> 2n + 6 >> 3n + 6 >> 3n + 2 >> 9n + 6]. f. This is difficult without completing D3(e), but solving 9n + 6 = 48 suggests that Mary’s original number was 4 2/3. g. Solving 9n + 6 = 30 shows that Joe’s original number was 2 2/3.

Problem D4

It’s pretty tough to draw a picture of the machine for “add the original number”! Specifically, the original number is a variable, so the results of that machine vary depending on what you put in to start. A machine labeled “+ n” might work, but notice how different that is from one that reads “+ 3”.

Problem D5

1. The final number will be 7.
2. The final number will be 7.
3. The final number will be 7.
4. The final number will be 7.
5. The final number will always be 7. The algorithm, starting with n, proceeds as n >> 3n >> 3n + 5 >> 6n + 10 >> 10 >> 14 >> 7. Note the step “subtract 6 times the original number” removes n completely, so the answer does not depend on n.
6. Since the answer is always 7, there is no way to determine what number Nancy was thinking of.

Problem D6

You almost need to know a formula for the entire algorithm before solving D3(f) and D3(g). In Problem D1, a “reverse” strategy will work, taking the algorithm step-by-step in reverse. But in Problem D3, the “add the original number” step is impossible unless you know the original number! So you could guess until you get it, or come up with a formula for the entire algorithm.

Problem D7

Here’s one: Pick a number, multiply it by 9, add 18, divide by 3, add 6, divide by 3 again, then subtract the original number. The answer will always be 4.