collatz: Computes the famous 3n + 1 sequence, also known as the...

Description Usage Arguments Value References Examples

Description

The Collatz conjecture, also known as the 3n + 1 problem, is a currently unsolved problem in number theory that is stated as: Start with a positive integer n If n is even, divide n by 2 If n is odd, multiply by 3 and add 1 to obtain 3n + 1 Repeat this process until the sequence reaches 1. It is unknown if there is a starting integer n that does not result in the sequence ending with 1.

Usage

1

Arguments

n

Starting integer to begin 3n + 1 process

Value

vector containing sequence generated by the Collatz conjecture. If n is 1, 1 is returned.

References

3x + 1 problem. (2017, May 13). In Wikipedia, The Free Encyclopedia. from https://en.wikipedia.org/wiki/Collatz_conjecture Moler, C. (2011). Numerical computing with MATLAB (1st ed.). Philadelphia, Pa: Society for Industrial & Applied Mathematics.

Examples

1
three_n_one(5)

aschleg/numberr documentation built on May 14, 2019, 10:31 a.m.