login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A258098 3x + 1 sequence starting at 79. 3

%I #22 Sep 08 2022 08:46:12

%S 79,238,119,358,179,538,269,808,404,202,101,304,152,76,38,19,58,29,88,

%T 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,

%U 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

%N 3x + 1 sequence starting at 79.

%F a(0) = 79; a(n) = 3*a(n - 1) + 1 if a(n - 1) is odd, a(n) = a(n - 1)/2 otherwise.

%e 79 is odd, so it's followed by 3 * 79 + 1 = 238.

%e 238 is even, so it's followed by 238/2 = 119.

%t NestList[If[EvenQ[#], #/2, 3# + 1] &, 79, 100]

%o (Scheme, with memoization-macro definec)

%o (definec (A258098 n) (if (zero? n) 79 (A006370 (A258098 (- n 1)))))

%o (define (A006370 n) (if (even? n) (/ n 2) (+ 1 n n n))) ;; Image of n under the `3x+1' map.

%o ;; _Antti Karttunen_, May 26 2015

%o (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

%o (Scala) def collatz(n: Int): Int = n % 2 match {

%o case 0 => n / 2

%o case _ => 3 * n + 1

%o }

%o def collatzSeq(n: Int): LazyList[Int] = LazyList.iterate(n)(collatz)

%o collatzSeq(79).take(100).toList // _Alonso del Arte_, Apr 26 2020

%Y Cf. A006370, A033478, A008874, A258056.

%Y Row 79 of A347270.

%K nonn,easy

%O 0,1

%A _Alonso del Arte_, May 19 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 28 09:38 EDT 2024. Contains 375481 sequences. (Running on oeis4.)