Giter Site home page Giter Site logo

collatz's Introduction

collatz badge

Collatz

This repo contain Erlang implementation for Collatz problem longest chain parallel computation.

The following iterative sequence is defined for the set of positive integers:

n → n/2 (n is even) n → 3n + 1 (n is odd)

Using the rule for number 13, we able generate the following sequence:

13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1

Length of this chain is 10 (9 step to reach 1).

The main idea of Collatz conjecture is if you take any positive integer "n" and if "n" is even, divide it by 2 to get n / 2 and if "n" is odd, multiply it by 3 and add 1 to obtain 3n + 1. Repeating the process (which has been called "Half Or Triple Plus One") indefinitely for any number (not proved) you will always reach 1.

The conjecture is that no matter what number you start with, you will always eventually reach 1.

This repo contain example how to find longest Collatz chain in range of numbers like {5,30} (start from 5, end 30).

Usage:

You need to build as release, or start erlang shell and run 'application:start(collatz).'

Then you can:

collatz:syn_longest_chain(1,1000000).
% you will get 525 here (524 step to reach 1)

It’s posible to define maximum number of workers in sys.config. For different ranges different value of maximum number of workers may be fair.

collatz's People

Contributors

spylik avatar

Stargazers

 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.