BOUNCY NUMBERS

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Explore an unsolved math problem with just using code!

To get started, head to Piper Make and hit this icon:

Time: 45 minutes

Age Range: 8+

Difficulty: Advanced

In this project, students will create bouncing numbers to illustrate the Collatz Conjecture.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Create quick basic commands for real world problems then link to coding concepts
  • Understand computational thinking concepts, including algorithms, sequence of instruction, and variables
  • Create programs that use variables to store and modify data
  • Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

STANDARDS ALIGNMENT

CSTA's K-12 Standards 

1B-CS-02: Model how computer hardware and software work together as a system to accomplish tasks. Subconcept: Hardware & Software; Practice 4.4

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one's own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

CCSS Math

CCSS.MATH.CONTENT.2.OA.C.3: Determine whether a group of objects (up to 20) has an odd or even number of members, e.g., by pairing objects or counting them by 2s; write an equation to express an even number as a sum of two equal addends.

CCSS.MATH.CONTENT.3.OA.A.1: Interpret products of whole numbers, e.g., interpret 5 × 7 as the total number of objects in 5 groups of 7 objects each.

CCSS.MATH.CONTENT.3.OA.A.2: Interpret whole-number quotients of whole numbers, e.g., interpret 56 ÷ 8 as the number of objects in each share when 56 objects are partitioned equally into 8 shares, or as a number of shares when 56 objects are partitioned into equal shares of 8 objects each.

CCSS.MATH.CONTENT.3.OA.D.9: Identify arithmetic patterns (including patterns in the addition table or multiplication table), and explain them using properties of operations.

CCSS.MATH.CONTENT.4.OA.C.5: Generate a number or shape pattern that follows a given rule. Identify apparent features of the pattern that were not explicit in the rule itself.

CCSS.MATH.CONTENT.5.OA.B.3: Generate two numerical patterns using two given rules. Identify apparent relationships between corresponding terms. Form ordered pairs consisting of corresponding terms from the two patterns, and graph the ordered pairs on a coordinate plane.

CCSS.MATH.CONTENT.5.NBT.A.4: Use place value understanding to round decimals to any place.

CCSS.MATH.CONTENT.5.G.A.2: Represent real world and mathematical problems by graphing points in the first quadrant of the coordinate plane, and interpret coordinate values of points in the context of the situation.

CCSS ELA

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

World-Class Instructional Design and Assessment (WIDA) English Language Proficiency Standards

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

California's K-12 Computer Science Standards

3-5.CS.2: Demonstrate how computer hardware and software work together as a system to accomplish tasks.

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

Math Content Standards

CCSS.MATH.CONTENT.2.OA.C.3: Determine whether a group of objects (up to 20) has an odd or even number of members, e.g., by pairing objects or counting them by 2s; write an equation to express an even number as a sum of two equal addends.

CCSS.MATH.CONTENT.3.OA.A.1: Interpret products of whole numbers, e.g., interpret 5 × 7 as the total number of objects in 5 groups of 7 objects each.

CCSS.MATH.CONTENT.3.OA.A.2: Interpret whole-number quotients of whole numbers, e.g., interpret 56 ÷ 8 as the number of objects in each share when 56 objects are partitioned equally into 8 shares, or as a number of shares when 56 objects are partitioned into equal shares of 8 objects each.

CCSS.MATH.CONTENT.3.OA.D.9: Identify arithmetic patterns (including patterns in the addition table or multiplication table), and explain them using properties of operations.

CCSS.MATH.CONTENT.4.OA.C.5: Generate a number or shape pattern that follows a given rule. Identify apparent features of the pattern that were not explicit in the rule itself.

CCSS.MATH.CONTENT.5.OA.B.3: Generate two numerical patterns using two given rules. Identify apparent relationships between corresponding terms. Form ordered pairs consisting of corresponding terms from the two patterns, and graph the ordered pairs on a coordinate plane.

CCSS.MATH.CONTENT.5.NBT.A.4: Use place value understanding to round decimals to any place.

CCSS.MATH.CONTENT.5.G.A.2: Represent real world and mathematical problems by graphing points in the first quadrant of the coordinate plane, and interpret coordinate values of points in the context of the situation.

Common Core English Language Arts

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

California English Language Development Standards

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

Michigan Integrated Technology Competencies for Students (MITECS)

1B-CS-02: Model how computer hardware and software work together as a system to accomplish tasks. Subconcept: Hardware & Software; Practice 4.4

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09 Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10 Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11 Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12 Modify, remix, or incorporate portions of an existing program into one's own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

Michigan Math Standards

2.OA.3: Determine whether a group of objects (up to 20) has an odd or even number of members, e.g., by pairing objects or counting them by 2s; write an equation to express an even number as a sum of two equal addends.

3.OA.1: Interpret products of whole numbers, e.g., interpret 5 × 7 as the total number of objects in 5 groups of 7 objects each.

3.OA.2: Interpret whole-number quotients of whole numbers, e.g., interpret 56 ÷ 8 as the number of objects in each share when 56 objects are partitioned equally into 8 shares, or as a number of shares when 56 objects are partitioned into equal shares of 8 objects each.

3.OA.9: Identify arithmetic patterns (including patterns in the addition table or multiplication table), and explain them using properties of operations.

4.OA.5: Generate a number or shape pattern that follows a given rule. Identify apparent features of the pattern that were not explicit in the rule itself.

5.OA.3: Generate two numerical patterns using two given rules. Identify apparent relationships between corresponding terms. Form ordered pairs consisting of corresponding terms from the two patterns, and graph the ordered pairs on a coordinate plane.

5.NBT.4: Use place value understanding to round decimals to any place.

5.G.2: Represent real world and mathematical problems by graphing points in the first quadrant of the coordinate plane, and interpret coordinate values of points in the context of the situation.

Michigan English Language Arts

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA English Language Development

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

Science Texas Essential Knowledge & Skills

Grade 3

(b)(2) Scientific investigation and reasoning. The student uses scientific practices during laboratory and outdoor investigations. The student is expected to:
(A) plan and implement descriptive investigations, including asking and answering questions, making inferences, and selecting and using equipment or technology needed, to solve a specific problem in the natural world;

(b)(3) Scientific investigation and reasoning. The student knows that information, critical thinking, scientific problem solving, and the contributions of scientists are used in making decisions.

Grade 4

(b)(3) Scientific investigation and reasoning. The student uses critical thinking and scientific problem solving to make informed decisions. The student is expected to:

    (A) analyze, evaluate, and critique scientific explanations by using evidence, logical reasoning, and experimental and observational testing;

Grade 5

(a)(1) In Grade 5, scientific investigations are used to learn about the natural world. Students should understand that certain types of questions can be answered by investigations and that methods, models, and conclusions built from these investigations change as new observations are made. Models of objects and events are tools for understanding the natural world and can show how systems work. They have limitations and based on new discoveries are constantly being modified to more closely reflect the natural world.

(a)(3) Recurring themes are pervasive in sciences, mathematics, and technology. These ideas transcend disciplinary boundaries and include patterns, cycles, systems, models, and change and constancy.

Math Texas Essential Knowledge & Skills

Grade 2
(7) Algebraic reasoning. The student applies mathematical process standards to identify and apply number patterns within properties of numbers and operations in order to describe relationships. The student is expected to:
(A) determine whether a number up to 40 is even or odd using pairings of objects to represent the number;

Grade 3
(4) Number and operations. The student applies mathematical process standards to develop and use strategies and methods for whole number computations in order to solve problems with efficiency and accuracy. The student is expected to:
(E) represent multiplication facts by using a variety of approaches such as repeated addition, equal-sized groups, arrays, area models, equal jumps on a number line, and skip counting;
(J) determine a quotient using the relationship between multiplication and division;

​​(5) Algebraic reasoning. The student applies mathematical process standards to analyze and create patterns and relationships.

Grade 4
(5) Algebraic reasoning. The student applies mathematical process standards to develop concepts of expressions and equations. The student is expected to:
(B) represent problems using an input-output table and numerical expressions to generate a number pattern that follows a given rule representing the relationship of the values in the resulting sequence and their position in the sequence;

Grade 5
(4) Algebraic reasoning. The student applies mathematical process standards to develop concepts of expressions and equations. The student is expected to:
(D) recognize the difference between additive and multiplicative numerical patterns given in a table or graph;

(8) Geometry and measurement. The student applies mathematical process standards to identify locations on a coordinate plane. The student is expected to:
(C) graph in the first quadrant of the coordinate plane ordered pairs of numbers arising from mathematical and real-world problems, including those generated by number patterns or found in an input-output table.

(2) Number and operations. The student applies mathematical process standards to represent, compare, and order positive rational numbers and understand relationships as related to place value. The student is expected to:
(C) round decimals to tenths or hundredths.

ELA Texas Essential Knowledge & Skills

Grade 3

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) speak coherently about the topic under discussion, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively;

    (D) work collaboratively with others by following agreed-upon rules, norms, and protocols; and

    (E) develop social communication such as conversing politely in all situations.

Grades 4 & 5

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) express an opinion supported by accurate information, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively; and

    (D) work collaboratively with others to develop a plan of shared responsibilities.

(b)(13) Inquiry and research: listening, speaking, reading, writing, and thinking using multiple texts. The student engages in both short-term and sustained recursive inquiry processes for a variety of purposes. The student is expected to:

    (A) generate and clarify questions on a topic for formal and informal inquiry;

    (B) develop and follow a research plan with adult assistance;

    (C) identify and gather relevant information from a variety of sources;

    (D) understand credibility of primary and secondary sources;

    (E) demonstrate understanding of information gathered;

    (F) differentiate between paraphrasing and plagiarism when using source materials;

    (G) develop a bibliography; and

    (H) use an appropriate mode of delivery, whether written, oral, or multimodal, to present results.

§74.4. English Language Proficiency Standards

(c) Cross-curricular second language acquisition essential knowledge and skills.

(3) Cross-curricular second language acquisition/speaking.

(D) speak using grade-level content area vocabulary in context to internalize new English words and build academic language proficiency;

(E) share information in cooperative learning interactions;

(F) ask and give information ranging from using a very limited bank of high-frequency, high-need, concrete vocabulary, including key words and expressions needed for basic communication in academic and social contexts, to using abstract and content-based vocabulary during extended speaking assignments;

(G) express opinions, ideas, and feelings ranging from communicating single words and short phrases to participating in extended discussions on a variety of social and grade-appropriate academic topics;

(H) narrate, describe, and explain with increasing specificity and detail as more English is acquired;

CONCEPTS

Students will explore the Collatz conjecture using logic, variables and loops.

PARTS

Raspberry Pi Pico, breadboard, charging cable

GPIO SETUP

none

OVERVIEW OF STEPS

Step 1: It's a Mystery!

Math can be used to solve a lot of problems, but did you know that there are a lot of questions that the study of mathematics does not know the answer to?

We are going to build a program that will help us explore one of these unsolved math problems called the Collatz Conjecture. It actually has a few other names, but mathematicians have not been able to prove if it's correct or not.

The rules of the Collatz Conjecture are actually pretty easy. You pick a number - it can be any positive whole number. If the number is even, you divide it by two. If the number is odd, you multiply it by 3 and then add 1.
After you apply this rule, you get a new number, and then you apply the rule again.

So far, every number that has been tried eventually becomes 1, and then it just loops and stops.

Even though every starting number that has ever been tried eventually becomes 1, mathematicians haven't been able to prove that all numbers will eventually become 1.

We are going to write a program that applies the rules of the Collatz Conjecture to any number that we pick and counts how many steps it takes to get to 1.

Click NEXT to get started.

Step 2: Ask for a Number

The first thing our program has to do is ask for a number from the user.

Grab a start block from the Chip menu and place it in the middle of the workspace. Since we are going to ask for a number, we are going to need to store that number.

Click the Variables menu and then click the Create Variable... button. Name your new variable "starting number". Then, grab the set starting number to block out and connect it to the start block.

When we ask a user a question, whatever they type in is going to be text. Your Pico can't do math with a text value, but we can convert a text value to a number value.

Grab the number from text block from the Values menu and place it inside the set starting number to block:
Now, we need to actually ask the user to type in a number. Grab the ask block from the Chip menu and place it inside of the number from text block. Then, in the "_" block, type "Enter a positive whole number":
Click NEXT.

Step 3: Check their Number

The first thing we need to do is make sure that the number they entered is positive, and that it's a whole number.

To make a number a whole number, all we have to do is round it. Grab a set starting number block from the Variables menu and connect it to the end of your program. Next, grab the round block from the Values menu and place it inside the set starting number block. Then, grab a starting number block from the Variables menu and place it inside the round block:
What if the user types in a negative number? We can use an if block to check! Grab an if _ = _ do block from the Logic menu and connect it to the end of your program. Next, grab a starting number block from the Variables menu and place it into the left side of the _ = _ block. Change the = to a >. Then, grab a 0 block from the Values menu and place it into the right side of the _ > _ block:
Now the user's number is ready!

Click NEXT.

Step 4: Keep it Going

If you remember the rules of the Collatz Conjuncture, whatever we do to the number, we do over and over again. This means we need a Loop! Do you remember where all of the numbers eventually end up? At 1! That means we need to keep looping until the number in the starting number variable is equal to 1.

Grab a repeat while _ block and place it into the if do block. Then, grab a _ = _ block from the Logic menu and place it in the input of the repeat while block. Grab a starting number block from the Variables menu and place it into the left side of the _ = _ block. Finally, grab a 0 block from the Values menu and place it into the right side of the _ = _ block. Change the 0 to a 1, and change the while to until:
Let's review the rules for the Collatz Conjecture. If the number is even, you divide it by two. If the number is odd, you multiply it by 3 and then add 1.
In order to apply the rules, we have to know if the number is even or odd.

Click NEXT.
 

Step 5: How Odd?

How can we tell if a number is even? An even number is a number that can be divided by two evenly. This means that if we have an even number of apples - like 8 apples, two people could share the apples evenly - they would each get 4 apples.

An odd number is a number that cannot be divided by two evenly. If you split up 7 apples between two people, both people would get three apples, and there would be one apple left over.

The easiest way to tell if a number is odd is to divide it by two and see if there is 1 left over!

How do we do that in our program? Good news, there is actually a block for that called the modulo operator, or mod for short. Modulo is a fancy way to say "remainder" after division.

8 mod 2 = 0 because there is nothing left over when you divide 8 by 2.

7 mod 2 = 1 because there is 1 left over when you divide 7 by 2.

We can determine if the starting number variable is even by seeing if starting number mod 2 = 0 is true.

Grab an if _ = _ do block from the Logic menu and place it into the repeat until block. Click the blue gear icon and in the mini workspace that opens up, drag an else block over and connect it below the if block. Then click the blue gear icon again to close the mini-workspace.

Grab a _ + _ block from the Logic menu and place it into the left side of the _ = _ block. Then, change the + (plus) to mod. Next, grab a starting number block from the Variables menu and place it into the left side of the _ mod _ block. Grab a 0 block from the Values menu and place it into the right side of the _ mod _ block. Change the 0 to 2. Finally, grab a 0 block from the Values menu and place it into the right side of the _ = _ block.

Click NEXT.

Step 6: Those are the Rules!

Now we have our if block that decides if the starting number is even or odd. Let's add the first rule: divide by two if it's even.

Grab a set starting number to block from the Variables menu and place it into the do part of the if do else block. Grab a _ + _ block from the Logic menu and place it into the input of the set starting number to block. Change the + (plus) to a ÷ (divide by). Grab a starting number block from the Variables menu and place it into the left side of the _ ÷ _ block. Then grab a 0 block from the Values menu and place it into the right side of the _ ÷ _ block. Change the 0 to a 2.

Now we need to apply the rule for odd numbers. Remember that we multiply it by 3 and then add 1.

Right-click the set starting number to block in the do part of the if do else block. Select Duplicate, and place the new blocks in the else part of the if do else block. Change the ÷ (divide by) on the new blocks to × (multiply by), and change the 2 to a 3. Adding 1 is easy - grab a change starting number by 1 block from the Variables menu and add it in right below the last set starting number to block.

That's it, right? How will we know what the program is even doing? We need to print out the starting number after each step!

Grab a print block from the Chip menu and connect it below the if do else block. Delete the "_" block by dragging it to the trash can. Then, grab a starting number block from the Variables menu and place it into the print block.

Almost there - but don't run your program yet!

Believe it or not, we actually need to slow down the Pico a little bit. If we run the program we have right now, it will print numbers to the CONSOLE way too fast!

Grab a wait block from the Chip menu and connect it right below the print block. Change the wait time to 0.02 seconds. That's still really fast, but slow enough for your computer to safely show the numbers in the CONSOLE.

Click NEXT.

Step 7: Try it out!

Your program is ready to try!

Click the CONSOLE tab at the bottom of the workspace to open the Console. Then, click CONNECT, choose your Pico, and click START.

The Console will ask you to "Enter a positive whole number". Click the console and type in a number. Then, press the enter/return key.

What number did you choose? You can see the result from typing in 24 above. Click START again to try running a different number.

Does each number take the same number of steps to reach 1? Can you find a number that takes less than 10 steps? Can you find a number that takes a lot of steps?

Let's add a step counter to see exactly how many steps a number takes to reach 1.

We'll need a new variable. Click the Variables menu and then click the Create variable... button. Name your new variable "step count". Grab the set step count to block and connect it right below the start block at the beginning of your program. Then, grab a 0 block from the Values menu and place it into the set step count to block.

Next, we need to add 1 to the step count variable each time the main loop repeats. Grab a change step count by block from the Variables menu and connect it right before the print block.

Now, let's print out how many steps it took at the end of our program. Grab a print "_" without newline block from the Chip menu and connect it to the end of your program. Type "That took " into the "_" block (notice that there is a space at the end!).

Grab another print "_" without newline block and connect it at the end of your program. Drag out the "_" block and delete it by dragging it to the trash can.

Then, grab a step count block from the Variables menu and place it into the last print without newline block.

Finally, grab a print "_" without newline block and connect it at the end of your program. Type " steps" into the "_" block.

Click START to try it again. This time, you'll get a count of the number of steps it took when the program finishes.

Click NEXT.

Step 8: Graph it!

Why is this tutorial called "Bouncy Numbers?"

You might have guess that when you run your program, the numbers go up and down quite a bit - but it's even more obvious when you graph the numbers.

Grab a graph number data block from the Actions menu and place it right between the print starting number block and the wait block. Then, grab a starting number block from the Variables menu and place it into the graph number values block.

Click START to run your program again. This time, try the number 27. When your program finishes, click the DATA tab at the bottom of the screen to see the graph of all the numbers.

Do you see how the number bounces up and down for a while before it finally settles to 1 at the end?

Click NEXT.

Step 9: Congratulations!

What are some ways you can change up your code to come up with a different number sequence? Could we change our code to use a random number for us instead of having to input our own number?

Give it a shot!
When you're ready to try some new tutorials or projects, click EXIT to go back to the start screen.