GithubHelp home page GithubHelp logo

bobossler / collatz-conjecture Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 19 KB

Python program testing the Collatz Conjecture, also known as the 3n+1 problem.

License: GNU General Public License v3.0

Python 100.00%

collatz-conjecture's Introduction

collatz-conjecture

Python program testing the Collatz Conjecture, also known as the 3n+1 problem.

What is the Collatz Conjecture?

The Collatz Conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with a positive integer n. Then each item is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.

For more info: Wikipedia

Purpose of the Program

I am writing a program that will confirm that when the Collatz Conjecture is applied to positive integers, the sequence will end with 1. This is not a proof. For more information on why the conjecture is not proven, see the link above.

The program flow:

  1. Take a starting positive integer
  2. Determine if the integer is even or odd
  3. If even, divide the integer by 2
  4. If odd, multiply the integer by 3 and add 1
  5. Check the result: if 1 end, else repeat

Program Usage

usage: collatz [-h] [-t] [-w] N

Compute the Collatz-Conjecture

positional arguments: N The starting integer to compute from

options: -h, --help show this help message and exit -t, --trajectory Display the highest number (trajectory) in the list -w, --wide Display the list horizontal rather than vertical

License


collatz.py is licensed under the GNU General Public License v3.0 or later

See LICENSE to see the full text.

Things To Do

  • Do more than just print results to screen; maybe write to a file
  • Integrate with a db to catalog all sequneces created

collatz-conjecture's People

Contributors

bobossler avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.