Skip to content

xzebcex/Collatz-sequence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Collatz sequence

Description

The Collatz sequence, also called the 3n + 1 problem, is the simplest impossible math problem. From a starting number, n, follow three rules to get the next number in the sequence: If n is even, the next number n is n / 2. If n is odd, the next number n is n * 3 + 1. If n is 1, stop. Otherwise, repeat. It is generally thought, but so far not mathematically proven, that every starting number eventually terminates at 1. This program demonstrates the Collatz sequence by taking a starting number from the user and generating the corresponding sequence of numbers.

Installing and Running

This program requires Python3 to be installed on your system in order to run. To execute the code, download or clone the repository and open the file collatz_sequence.py" in a Python environment.

How to Implement

When you execute the source code, it will prompt you to provide a starting number (greater than 0) or to leave. If the user enters a valid integer, the application will produce and show the appropriate Collatz sequence on the screen.

Add a License

This code is distributed under the MIT License.

How to Contribute

Contributions to the program are much welcomed. Even though this application is fully working, code contributions are always appreciated. If you have any recommendations or improvements, fork the repository, make modifications or additions to the code, and submit a pull request.

Additional Points

This program is suitable for beginners who are learning Python programming language. The program uses the time module to delay the output by 0.1 seconds to make it easier to read.

Conclusion

This program provides a simple way to demonstrate the Collatz sequence and helps users understand the basics of Python programming. Feel free to use and modify the code to suit your needs.

About

The Collatz sequence, also called the 3n + 1 problem, is the simplest impossible math problem.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages