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
Index entries for linear recurrences with constant coefficients, signature (0,0,1).
MAPLE
f := proc(n) option remember; if n = 0 then 33; 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] &, 33, 100] (* Vincenzo Librandi, Jul 29 2014 *)
PROG
(Magma) [n eq 1 select 33 else IsOdd(Self(n-1)) select 3*Self(n-1)+1 else Self(n-1) div 2: n in [1..80]]; // 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(33).take(100).toList // Alonso del Arte, Apr 25 2020
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved