Skip to contents

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 https://github.com/Skenvy/Collatz/releases/download/R-v${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")'

Usage

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.

Developing

The first time setup

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

git clone https://github.com/Skenvy/Collatz.git && cd Collatz/R && sudo make setup_debian && make setup && make setup_libraries

Iterative development

  • make docs_local to start a local server to browse the docs generated by roxygen2, pkgdown, covr, Rd2pdf and TinyTex, served by servr.
  • make full_test will verify the integrity of the package after passing the tests, as passing the tests is a lower threshold than package structure.