Skip to content

About

A simple Python program that demonstrates the Collatz Conjecture. It takes a positive integer, applies the even/odd rules, and prints each resulting step until the sequence reaches 1. Includes input validation and clear output, making it easy to follow the sequence’s progression.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

📘 Project Description: Collatz Conjecture Step-by-Step Simulator

This project provides a simple, interactive Python program that demonstrates the Collatz Conjecture, one of the most famous unsolved problems in mathematics. The conjecture proposes that if you start with any positive integer and repeatedly apply a specific rule, you will always eventually reach 1.

This script allows users to enter any positive integer and then visually follow each step of the Collatz process as the number evolves. The program prints whether the current value is even or odd, shows the transformation applied, and displays the updated result until the sequence reaches 1.

🧠 How the Collatz Conjecture Works

For any positive integer n:

If n is even:
Apply         n = n / 2

If n is odd:
Apply         n = 3n + 1

The conjecture states that no matter which number you start with, repeating these rules will always end in 1.

This program implements that logic interactively and prints each transformation so you can observe the sequence evolving in real time.

⚙️ What the Script Does

Prompts the user to enter a valid positive integer.

Validates input to ensure only digits are accepted.

Processes the number through Collatz steps:

If even → divides by 2

If odd → applies 3n + 1

Prints detailed output each step:

Whether the number is even or odd

The exact operation used

The resulting value

Stops when the value reaches 1 and prints a final “success” message.

🎯 Purpose of This Project

This script is designed for:

beginners learning Python

students exploring mathematical sequences

anyone curious about the Collatz Conjecture

GitHub repositories showcasing algorithmic logic

teaching step-by-step computation

experimenting with number theory

It is intentionally written in a clear, readable form to help study the algorithmic behavior of the sequence.

📌 Features

Input validation

Infinite loop safely terminates on success

Clear, readable printed output

Pure Python (no external libraries required)

Ideal for demonstration or teaching

📝 Summary

This script serves as a simple “ripper” that breaks down a starting integer into its Collatz sequence step by step. It shows the full reasoning process of the conjecture in action—how each number transforms based on even/odd rules—until the sequence finally collapses to 1.

It’s a compact but powerful demonstration of a famous unsolved mathematical problem, presented in an accessible and beginner-friendly way.

About

A simple Python program that demonstrates the Collatz Conjecture. It takes a positive integer, applies the even/odd rules, and prints each resulting step until the sequence reaches 1. Includes input validation and clear output, making it easy to follow the sequence’s progression.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages