A series of programs used to compute integers against the Collatz conjecture. https://kyle.so
  • Go 55.9%
  • TypeScript 23.2%
  • Python 20.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-03-15 03:24:29 -06:00
go go: add comments 2025-03-15 03:24:29 -06:00
python change output formatting 2024-10-07 21:33:56 +00:00
typescript change output formatting 2024-10-07 21:33:56 +00:00
.gitignore go: update sequential, allow starting at specified n 2025-01-28 23:50:58 -07:00
.prettierrc python algo 2024-10-03 20:42:19 +00:00
LICENSE Initial commit 2024-10-03 14:09:17 -06:00
README.md readme: update algos 2025-01-28 22:45:05 -07:00

Collatz Conjecture Explorer

This repository contains a collection of programs designed to explore the fascinating Collatz conjecture, also known as the 3n + 1 problem. It builds upon and extends the work from an earlier, now archived repository here.

Read about the conjecture here.

Algorithms in this repo. are listed here. I recommend using the Go program, as it's the fastest and most efficient.

The Collatz Conjecture: An Enigmatic Mathematical Puzzle

The Collatz conjecture, named after the mathematician Lothar Collatz, is the most intriguing unsolved problem in mathematics (in my opinion). It's deceptively simple to state, yet has resisted proof for decades.

The conjecture works as follows:

  1. Start with any positive integer n.
  2. If n is even, divide it by 2.
  3. If n is odd, multiply it by 3 and add 1.
  4. Repeat steps 2 and 3 until n=1.

The conjecture posits that no matter what number you start with, you will always eventually reach 1, entering the loop 4 → 2 → 1.

Mathematically, this can be expressed as:

f(n) = {
    n/2     if n is even
    3n + 1  if n is odd
}

While every number tested so far has been shown to reach the 4-2-1 loop, a rigorous mathematical proof for all positive integers remains elusive.

Project Overview

This repository houses a series of programs implemented in various programming languages. The primary goals of this project are:

  1. To provide educational resources for understanding the Collatz conjecture.
  2. To offer efficient tools for computing Collatz sequences and analyzing their properties.
  3. To serve as a platform for exploring algorithmic approaches to mathematical problems.

It's important to note that these programs are not aimed at proving the conjecture. Instead, they allow users to experiment with the conjecture, visualize sequences, and potentially discover interesting patterns or behaviors.

Algorithms

  • Collatz.py is a Python program that implements the Collatz algorithm to calculate the Collatz sequence for a given number. It also allows users to sequentially calculate every number until they cancel.

  • Collatz.ts is a TypeScript program that implements the Collatz algorithm to calculate the Collatz sequence for a given number. It also allows users to sequentially calculate every number until they cancel.

  • Collatz.go is a Go program that implements the Collatz algorithm to calculate the Collatz sequence for a given number. It also allows users to sequentially calculate every number until they cancel.