Code Monkey home page Code Monkey logo

collatz's Introduction

Collatz Conjecture Solver

This project is a Go application that attempts to solve the Collatz Conjecture using two methods: a seed-based approach and a brute force approach.

The calculation utilises big.Int and can represent integers as large as can fit in your computer's memory. There is no theoretical limit to the size of a big.Int number, the limit is only practical and depends on the amount of memory your computer has.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Usage

  1. Download the collatz.zip file from the repository.
  2. Extract the collatz.zip file to get the collatz binary.
  3. Open a terminal and navigate to the directory containing the collatz binary.
  4. Run the binary with the desired mode (seed or bruteforce) and the necessary arguments.

Calculate the Collatz Conjecture

seed screenshot

./collatz seed -number=<number>
  • Replace <number> with the number you want to calculate the Collatz Conjecture.

Example:

./collatz seed -number=27

Bruteforce Calculate the Collatz Conjecture

bruteforce screenshot

./collatz bruteforce begin=<start_number> end=<end_number>
  • Replace <start_number> with the number you want to start the sequence from.
  • Replace <end_number> with the number you want to end the sequence at.

Example:

./collatz bruteforce begin=0 end=1234567890
./collatz bruteforce -end=1000000 -print-all | sed -E 's/level=INFO msg="([^"]+)"/\1/' | sed -E 's/number: ([0-9]+), steps: ([0-9]+), max: ([0-9]+)/\1,\2,\3/' > example.txt

Help

More options can be found by running the following command:

./collatz --help

Prerequisites

  • Go version 1.23 or higher

Installation

  1. Ensure you have Go version 1.23 or higher installed on your machine.
  2. Clone the repository to your local machine.
  3. Navigate to the project directory.
  4. Run go mod download to download the necessary dependencies.

Building the Application

The application can be run in two modes: seed and bruteforce.

make build: Builds the project and outputs the binary in out/bin/.

Using the Makefile

The Makefile includes several commands that help with building, testing, and linting the application.

Builds the project and outputs the binary in out/bin/.

make build

Removes build related files.

make clean

Runs the tests.

make test

Runs the tests and exports the coverage.

make coverage

Runs golang linting.

make lint

Shows help information for the Makefile commands.

make help

collatz's People

Contributors

jfallis avatar

Stargazers

 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.