Code Monkey home page Code Monkey logo

collatz-conjecture-logs's Introduction

Collatz-Conjecture (3n+1)

This Collatz-Conjecture (3n+1) algorithm prints each calculated sequence in a given interval of integers.


The Collatz-Conjecture is a conjecture in mathematics that concerns a sequence defined as follows:

  1. Start with any positive integer n.
  2. Then each term is obtained from the previous term. If the previous term is even, the next term is half of the previous term. If the previous term is odd, the next term is x3 the previous term, plus 1.
The Collatz-Conjecture Expression

The conjecture is that no matter what value of n, the sequence will always reach 1 at some point.

What does this program do?

For each number tested in the interval

  • Lists all the visited numbers in order (e.g 5, 16, 8, 4, 2, 1),

Output post calculation

  • Largest integer reached

  • What iteration had the largest integer

  • The longest sequence

  • Total count of nodes (numbers) visited

  • Number of sequences calculated

Different languages

Python

Preferably executed with python3, python 3NPlus1.py in terminal.

In 3NPlus1.py the max number to calculate is defined on line 29.

Default max value: 50

26 ...
27 
28 def main():
29      upper_limit = 50
30
31 ...

Node.js

Preferably executed in terminal using node 3NPlus1.js .

In 3NPlus1.js the interval of numbers to calculate is defined on line 5.

Default max value: 50

3 ...
4 */
5 const stats = await startCount(1,50);
6
7 ...

C/C++

Preferably executed with gcc, gcc 3NPlus1.c. Then run the executable in the terminal.

In 3NPlus1.c the max number to calculate is defined on line 33.

Default max value: 50

30 ...
31
32 int main() {
33      int upperLimit = 50;   
34      ...

collatz-conjecture-logs's People

Contributors

caisesiume avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.