Code Monkey home page Code Monkey logo

collatz-conjecture's Introduction

Collatz-Conjecture

The visual representation of The Simplest Math Problem No One Can Solve. (3N+1 Problem)

AKA The 3N+1 Problem.

The infamous Collatz conjecture says that if you start with any positive integer, you’ll always end up in this loop.

The result, at some point, will end up in a loop of 4,2,1.

How does this work?

I'll suggest you watch The Simplest Math Problem No One Can Solve by Veritasium. Or read The Simple Math Problem We Still Can’t Solve

Basically what it does is that when we give some number as an input, it checks if it's odd or even. If the number is odd, it'll multiply it by 3 and add 1. And if the number is even it'll divide it by 2.

It will keep on doing it and after some time, it'll reach at a point where it'll be in a loop of 4 -> 2 -> 1 -> 4 -> 2 ->...

Contributing

If you think something's missing or can be added. Do let me know in the issues or Just give a Pull Request!

collatz-conjecture's People

Contributors

piyushsuthar avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

collatz-conjecture's Issues

Prime number

I think the reason it ends in a loop is that the division is done using 2 which is the only figure that is both an even number and a prime number. If another even number is used for the division of ń, we may not arrive at a loop. As the smallest even number in the series won't be equal to '2'.

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.