Fiddler on the Proof: Jan 5, 2024

David Ding

Jan 5, 2024

Collatz 2024

What is the smallest starting positive integer for which 2024 appears somewhere in the sequence?

399

Explanation:

I used the following Python script to search exhaustively for the answer, which turns out to be 399.

def find_smallest_starting_number(target):
    starting_number = 1
    while True:
        sequence = [starting_number]
        current = starting_number
        while current != 1:
            if current % 2 == 0:
                current = current // 2
            else:
                current = 3 * current + 1
            sequence.append(current)

            # Check if the target appears in the sequence
            if target in sequence:
                return starting_number

        starting_number += 1

# Find the smallest starting number for which 2024 appears in its Collatz sequence
target_number = 2024
result = find_smallest_starting_number(target_number)
print(f"The smallest starting number for which {target_number} appears in its Collatz sequence is: {result}")

Output:

The smallest starting number for which 2024 appears in its Collatz sequence is: 399