amritansh22 / Data-Structures-and-Algorithms-in-cpp

This repository is in development phase and will soon provide you with c++ code of various data structures and algorithms
MIT License
366 stars 341 forks source link

Collatz Conjecture Added #578

Open Cotex05 opened 2 years ago

Cotex05 commented 2 years ago

The Collatz conjecture is a conjecture in mathematics that concerns sequences defined as follows: start with any positive integer n. Then each term 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.

Consider the following operation on an arbitrary positive integer: If the number is even, divide it by two. If the number is odd, triple it and add one. For every number, consecutive operation as per the condition converges the number to 1.

welcome[bot] commented 2 years ago

Thanks for opening this pull request! Please be sure that you have checked out our contributing guidelines.