Collatz: R 🏴‍☠️🔵🦜

Functions related to the Collatz/Syracuse/3N+1 problem, implemented in R.

Getting Started

To install the latest from github, with devtools;

Rscript -e 'devtools::install_github("Skenvy/Collatz", subdir="R")'

To install a specific GitHub release’s tarball (all R-v* tagged releases include a collatz_*.tar.gz, simply copy the below and change the example version from 0.1.0 to whichever version you want);

VER=1.0.0 && curl -L${VER}/collatz_${VER}.tar.gz > collatz_${VER}.tar.gz && Rscript -e "install.packages('collatz_${VER}.tar.gz', repos=NULL, type='source')"

To install the latest from CRAN (relevancy pending the submission to CRAN and its ongoing stability);

Rscript -e 'install.packages("collatz")'


Provides the basic functionality to interact with the Collatz conjecture. The parameterisation uses the same (P,a,b) notation as Conway’s generalisations. Besides the function and reverse function, there is also functionality to retrieve the hailstone sequence, the “stopping time”/“total stopping time”, or tree-graph. The only restriction placed on parameters is that both P and a can’t be 0.

Roxygen2+Pkgdown generated docs

Covr+DT generated Coverage

Rd2pdf+TinyTex Generated PDF


The first time setup

On a debian system, this should be most of the required setup.

git clone && cd Collatz/R && sudo make setup_debian && make setup && make setup_libraries

Iterative development