Skip to main content
Follow the Collatz rule from any starting number down to 1, printing each number and counting the steps. Open Lab 13 in the IP Lab Portal

What you will practice

  • Write a loop whose length is not known in advance
  • Branch on even and odd values
  • Count the steps taken

Before you start

Time

20 minutes

Where

IP Lab Portal

Module

Module 5: Loops

  • In the IP Lab Portal, open Lab 13 - Collatz sequence.
  • In class, this lab comes right after the Lesson 5 recap slide in Module 5 core material.