Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/g1eng/cola2
An ancient Collatz map solver
https://github.com/g1eng/cola2
numerical-calculations rust
Last synced: about 2 months ago
JSON representation
An ancient Collatz map solver
- Host: GitHub
- URL: https://github.com/g1eng/cola2
- Owner: g1eng
- License: mit
- Created: 2021-11-14T10:47:05.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-11-20T15:18:15.000Z (about 3 years ago)
- Last Synced: 2023-10-20T19:55:48.713Z (about 1 year ago)
- Topics: numerical-calculations, rust
- Language: Rust
- Homepage:
- Size: 1.05 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
COLA2 is a simple solver program for Collatz conjecture (known as `3n+1` problem).
About Collatz conjencture, see [wikipedia](https://en.wikipedia.org/wiki/3n%2B1).In this program, the map for even `n|->n/2` is called A, and the map for odd `n|->3n+1` is called B.
# Requirement
* rustc (>=1.53.0 recommended)
# Installation
For Unix-like operating system, simply make it:
```
make
make install
```# Usage
## 1. give numbers via pipeline
```
echo 153 | cola2
153 36
echo 155555555555555555555555555553 | cola2
155555555555555555555555555553 901
```## 2. give numbers from a file
```
for i in {1..8}; do
echo 2^$i-1 | bc
done > num.dat
cola2 < num.dat
1 0
3 7
7 16
15 17
31 106
63 107
127 46
255 47
```## 3. interactive
`cola2 `
# Tips: Make dot file to visualize convergence process
Following sample script generates a DOT file to visualize Collatz map for numbers less than 257:
```
{
echo strict digraph map \{
for i in {1..256}
do
echo $i | cola2 -d
done
echo \}
} > collatz_map.dot
```![Collatz map 256](docs/sample.png)
# Author
Nomura Suzume