Skip to content

mourtallah/CollatzGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Collatz Sequence

The Collatz sequence is a sequence of numbers in which each term is either the number 1 or the result of multiplying the previous number in the sequence by either 3 or 1. It is also known as the 3x+1 problem.

The Collatz sequence is important in mathematics because it is a simple and fascinating example of a mathematical sequence that exhibits complex behavior. It has been studied extensively and has applications in various fields, including number theory, cryptography, and computer science.

In this project, you will implement a Python function that takes a positive integer as input and generates the Collatz sequence starting from that number. The function will print each number in the sequence and the number of steps it takes to reach the number 1.

Usage

To use this project, follow these steps:

  1. Clone this repository to your local machine.
  2. Navigate to the project directory.
  3. Run the collatz_sequence.py file with the desired input.

For example, to generate the Collatz sequence for the number 10, you can run the following command:

python collatz_sequence.py 10

Output

The output will be the Collatz sequence starting from the input number. Each number in the sequence will be printed on a new line, along with the number of steps it takes to reach the number 1.

Example

Here is an example of the output for the input number 10:

10 5 16 8 4 2 1

In this example, the Collatz sequence starts with the number 10. Each subsequent number in the sequence is obtained by either multiplying the previous number by 3 and adding 1, or by dividing the previous number by 2. The sequence ends with the number 1, which is the final number in the sequence.

Contributing

If you would like to contribute to this project, please follow these steps:

  1. Fork this repository.
  2. Create a new branch for your changes.
  3. Make your changes and commit them.
  4. Push your changes to your forked repository.
  5. Create a pull request to merge your changes into the main repository.

Please note that all contributions should be properly formatted and include a detailed description of the changes made.

License

This project is licensed under the MIT Common License.

About

A Simple Command Line Collatz Sequence Generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages