top of page

Collatz conjecture

Lesson Overview

This lesson immerses students in the challenge of the Collatz Conjecture, a deceptively simple mathematical conjecture that remains unsolved. By programming the conjecture's process in Scratch, students will deepen their comprehension of sequences, enhance their algorithmic thinking, and appreciate the unpredictable nature of mathematical patterns.

Learning Objectives

  • Sequence Comprehension: Investigate mathematical sequences, recognizing how iteration generates complex patterns from fundamental rules.

  • Programming Proficiency in Scratch: Enhance coding skills by mastering loops and conditional logic to unravel math challenge.

Task Description and Resources

(1) Understanding the Collatz Conjecture

The Collatz conjecture posits that starting with any positive integer, applying a simple rule—divide by two if the number is even, or multiply by three and add one if it's odd—will eventually lead all numbers to enter a repeating cycle of 4, 2, 1.

Objective: Familiarize students with the Collatz Conjecture and its implications.

Suggested Step: Discuss the conjecture’s statement and its status as an unsolved problem in mathematics, encouraging students to think about why such a simple rule leads to complex behavior and whether they believe every number truly leads to the cycle 4, 2, 1.

(2) Implementing the Conjecture in Scratch

Problem Statement: Create a Scratch program that takes a positive integer as input and generates the sequence dictated by the Collatz Conjecture, iterating until reaching the terminal cycle of 4, 2, 1.

Suggested Steps:

  • Create a function to input a positive integer.

  • Utilize a loop to apply the Collatz rules: divide by two for even numbers, or multiply by three and add one for odd numbers.

  • Record each step in the sequence, possibly using a list to visually display the progression.

  • Continue iterating until the sequence arrives at the number 1, thereby reaching the conjecture's terminal cycle.

Reference Code:



Through this lesson, students will not only explore an unsolved problem in the Collatz Conjecture, but also make use of critical mathematical and programming concepts. The activity is designed to make abstract mathematical ideas tangible and to show how programming can be a powerful tool for exploring mathematical phenomena. This hands-on approach encourages students to foster a deeper understanding of mathematics and computer science.


The author would like to thank Ka Ying LIU and Zhi Hao CUI for designing this lesson and appreciate all the anonymous teachers and students who participated in this research.

bottom of page