OFFSET
0,1
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, E16.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..200
Darrell Cox, The 3n + 1 Problem: A Probabilistic Approach, Journal of Integer Sequences, Vol. 15 (2012), #12.5.2.
Index entries for linear recurrences with constant coefficients, signature (0,0,1).
FORMULA
From Colin Barker, Apr 27 2020: (Start)
G.f.: (81 + 244*x + 122*x^2 - 20*x^3 - 60*x^4 - 30*x^5 - 15*x^6 - 161*x^7 - 22*x^8 - 11*x^9 + 83*x^10 - 17*x^11 + 125*x^12 - 26*x^13 - 13*x^14 - 140*x^15 - 70*x^16 - 35*x^17 - 4*x^18 - 2*x^19 - x^20 - 14*x^21 - 7*x^22) / ((1 - x)*(1 + x + x^2)).
a(n) = a(n-3) for n>22.
(End)
MAPLE
f := proc(n) option remember; if n = 0 then 81; elif f(n-1) mod 2 = 0 then f(n-1)/2 else 3*f(n-1)+1; fi; end;
MATHEMATICA
NestList[If[EvenQ[#], #/2, 3# + 1]&, 81, 100] (* Vincenzo Librandi, Jul 29 2014 *)
PROG
(Haskell)
a008876 n = a008876_list !! n
a008876_list = 81 : iterate a006370 81
-- Reinhard Zumkeller, Aug 30 2012
(Magma) [n eq 1 select 81 else IsOdd(Self(n-1)) select 3*Self(n-1)+1 else Self(n-1) div 2: n in [1..70]]; // Vincenzo Librandi, Jul 29 2014
(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(81).take(100).toList // Alonso del Arte, Apr 24 2020
(PARI) Vec((81 + 244*x + 122*x^2 - 20*x^3 - 60*x^4 - 30*x^5 - 15*x^6 - 161*x^7 - 22*x^8 - 11*x^9 + 83*x^10 - 17*x^11 + 125*x^12 - 26*x^13 - 13*x^14 - 140*x^15 - 70*x^16 - 35*x^17 - 4*x^18 - 2*x^19 - x^20 - 14*x^21 - 7*x^22) / ((1 - x)*(1 + x + x^2)) + O(x^70)) \\ Colin Barker, Apr 27 2020
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved