A258098 3x + 1 sequence starting at 79.
79, 238, 119, 358, 179, 538, 269, 808, 404, 202, 101, 304, 152, 76, 38, 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4
Offset: 0
Examples
79 is odd, so it's followed by 3 * 79 + 1 = 238. 238 is even, so it's followed by 238/2 = 119.
Programs
-
Magma
[n eq 1 select 79 else IsOdd(Self(n-1)) select 3*Self(n-1)+1 else Self(n-1) div 2: n in [1..100]]; // Vincenzo Librandi, May 27 2015
-
Mathematica
NestList[If[EvenQ[#], #/2, 3# + 1] &, 79, 100]
-
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(79).take(100).toList // Alonso del Arte, Apr 26 2020
Formula
a(0) = 79; a(n) = 3*a(n - 1) + 1 if a(n - 1) is odd, a(n) = a(n - 1)/2 otherwise.