cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A033479 3x+1 sequence beginning at 9.

This page as a plain text file.
%I A033479 #29 Nov 17 2021 17:02:22
%S A033479 9,28,14,7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,4,2,1,4,2,
%T A033479 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,
%U A033479 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
%N A033479 3x+1 sequence beginning at 9.
%H A033479 Colin Barker, <a href="/A033479/b033479.txt">Table of n, a(n) for n = 0..1000</a>
%H A033479 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%H A033479 <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,1).
%F A033479 From _Colin Barker_, Oct 04 2019: (Start)
%F A033479 G.f.: (9 + 28*x + 14*x^2 - 2*x^3 - 6*x^4 - 3*x^5 + 27*x^6 - 5*x^7 + 41*x^8 - 8*x^9 - 4*x^10 - 12*x^11 - 6*x^12 - 3*x^13 - 35*x^14 - 4*x^15 - 2*x^16 - x^17 - 14*x^18 - 7*x^19) / ((1 - x)*(1 + x + x^2)).
%F A033479 a(n) = a(n-3) for n>19.
%F A033479 (End)
%e A033479 9 is odd, so the next term is 3*9 + 1 = 28.
%e A033479 28 is even, so the next term is 28/2 = 14.
%t A033479 NestList[If[EvenQ[#], #/2, 3# + 1] &, 9, 100] (* _Harvey P. Dale_, Dec 16 2012 *)
%o A033479 (Scala) def collatz(n: Int): Int = (n % 2) match {
%o A033479   case 0 => n / 2
%o A033479   case 1 => 3 * n + 1
%o A033479 }
%o A033479 import scala.collection.mutable.ListBuffer
%o A033479 val start = 9; var curr = start; var trajectory = new ListBuffer[Int]()
%o A033479 for (_ <- 1 to 100) {
%o A033479   trajectory += curr; curr = collatz(curr)
%o A033479 }
%o A033479 trajectory // _Alonso del Arte_, Jun 02 2019
%o A033479 (PARI) Vec((9 + 28*x + 14*x^2 - 2*x^3 - 6*x^4 - 3*x^5 + 27*x^6 - 5*x^7 + 41*x^8 - 8*x^9 - 4*x^10 - 12*x^11 - 6*x^12 - 3*x^13 - 35*x^14 - 4*x^15 - 2*x^16 - x^17 - 14*x^18 - 7*x^19) / ((1 - x)*(1 + x + x^2)) + O(x^80)) \\ _Colin Barker_, Oct 04 2019
%o A033479 (Python)
%o A033479 from itertools import accumulate
%o A033479 def f(x, _): return x//2 if x%2 == 0 else 3*x+1
%o A033479 print(list(accumulate([9]*92, f))) # _Michael S. Branicky_, Sep 28 2021
%Y A033479 Cf. A070165.
%Y A033479 Row 9 of A347270.
%K A033479 nonn,easy
%O A033479 0,1
%A A033479 _Jeff Burch_