OFFSET
0,1
COMMENTS
Previous name was "x -> x/2 if x even, x -> 3x - 1 if x odd."
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, E16.
LINKS
Colin Barker, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,1).
FORMULA
a(0) = 36, a(n) = a(n - 1)/2 if a(n - 1) is even, otherwise 3a(n - 1) - 1.
From Colin Barker, Apr 26 2020: (Start)
G.f.: (36 + 18*x + 9*x^2 + 26*x^3 + 13*x^4 + 2*x^5 + x^6 + 47*x^7 + 2*x^8 + x^9 - 31*x^10 + x^11 - 46*x^12 - 23*x^13) / ((1 - x)*(1 + x + x^2 + x^3 + x^4)).
a(n) = a(n - 5) for n > 13.
(End)
MATHEMATICA
-NestList[If[EvenQ[#], #/2, 3# + 1] &, -36, 100] (* Alonso del Arte, Apr 26 2020 *)
PROG
(Scala) def collatz(n: Int): Int = n % 2 match {
case 0 => n / 2
case _ => 3 * n + 1
}
def collatzSeq(n: Int): LazyList[Int] = LazyList.iterate(n)(collatz)
collatzSeq(-36).take(100).toList.map(_ * -1) // Alonso del Arte, Apr 26 2020
(PARI) Vec((36 + 18*x + 9*x^2 + 26*x^3 + 13*x^4 + 2*x^5 + x^6 + 47*x^7 + 2*x^8 + x^9 - 31*x^10 + x^11 - 46*x^12 - 23*x^13) / ((1 - x)*(1 + x + x^2 + x^3 + x^4)) + O(x^70)) \\ Colin Barker, Apr 26 2020
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
More specific name from Alonso del Arte, Apr 26 2020
STATUS
approved