Introduction
This section contains additional exercises to practice the concepts learned in the previous sections. This is still work in progress, so more exercises will be added over time.
Exercise 1
Write a function collatz that takes a positive integer n as an argument and returns a list of the Collatz sequence starting with n. The Collatz sequence is defined as follows: if n is even, the next number is half of n. If n is odd, the next number is three times n plus 1. The sequence ends when it reaches 1.
This document is licensed under the CC BY-NC-SA 4.0 by Clemens Brunner.