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.

A025586 Largest value in '3x+1' trajectory of n.

This page as a plain text file.
%I A025586 #79 Mar 27 2024 10:42:33
%S A025586 1,2,16,4,16,16,52,8,52,16,52,16,40,52,160,16,52,52,88,20,64,52,160,
%T A025586 24,88,40,9232,52,88,160,9232,32,100,52,160,52,112,88,304,40,9232,64,
%U A025586 196,52,136,160,9232,48,148,88,232,52,160,9232,9232,56,196,88,304,160,184,9232
%N A025586 Largest value in '3x+1' trajectory of n.
%C A025586 Here by definition the trajectory ends when 1 is reached. Therefore this sequence differs for n = 1 and n = 2 from A056959, which considers the orbit ending in the infinite loop 1 -> 4 -> 2 -> 1.
%C A025586 a(n) = A220237(n,A006577(n)). - _Reinhard Zumkeller_, Jan 03 2013
%C A025586 A006885 and A006884 give record values and where they occur. - _Reinhard Zumkeller_, May 11 2013
%C A025586 For n > 2, a(n) is divisible by 4. See the explanatory comment in A056959. - _Peter Munn_, Oct 14 2019
%C A025586 In an email of Aug 06 2023, Guy Chouraqui observes that the digital root of a(n) appears to be either 7 or a multiple of 4 for all n > 2.  (See also A006885.) - _N. J. A. Sloane_, Aug 11 2023
%H A025586 T. D. Noe, <a href="/A025586/b025586.txt">Table of n, a(n) for n = 1..10000</a>
%H A025586 Christian Hercher, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL26/Hercher/hercher5.html">There are no Collatz m-Cycles with m <= 91</a>, J. Int. Seq. (2023) Vol. 26, Article 23.3.5.
%H A025586 Philippe Picart, <a href="http://trucsmaths.free.fr/js_syracuse.htm">Algorithme de Collatz et conjecture de Syracuse</a>
%H A025586 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%e A025586 The 3x + 1 trajectory of 9 is 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 (see A033479). Since the largest number in that sequence is 52, a(9) = 52.
%p A025586 a:= proc(n) option remember; `if`(n=1, 1,
%p A025586       max(n, a(`if`(n::even, n/2, 3*n+1))))
%p A025586     end:
%p A025586 seq(a(n), n=1..87);  # _Alois P. Heinz_, Oct 16 2021
%t A025586 collatz[a0_Integer, maxits_:1000] := NestWhileList[If[EvenQ[#], #/2, 3# + 1] &, a0, Unequal[#, 1, -1, -10, -34] &, 1, maxits]; (* collatz[n] function definition by Eric Weisstein *) Flatten[Table[Take[Sort[Collatz[n], Greater], 1], {n, 60}]] (* _Alonso del Arte_, Nov 14 2007 *)
%t A025586 collatzMax[n_] := Module[{r = m = n}, While[m > 2, If[OddQ[m], m = 3 * m + 1; If[m > r, r = m], m = m/2]]; r]; Table[ collatzMax[n], {n, 100}] (* _Jean-François Alcover_, Jan 28 2015, after _Charles R Greathouse IV_ *)
%t A025586 (* Using Weisstein's collatz[n] definition above *) Table[Max[collatz[n]], {n, 100}] (* _Alonso del Arte_, May 25 2019 *)
%o A025586 (PARI) a(n)=my(r=n);while(n>2,if(n%2,n=3*n+1;if(n>r,r=n),n/=2));r \\ _Charles R Greathouse IV_, Jul 19 2011
%o A025586 (Haskell)
%o A025586 a025586 = last . a220237_row
%o A025586 -- _Reinhard Zumkeller_, Jan 03 2013, Aug 29 2012
%o A025586 (Python)
%o A025586 def a(n):
%o A025586     if n<2: return 1
%o A025586     l=[n, ]
%o A025586     while True:
%o A025586         if n%2==0: n//=2
%o A025586         else: n = 3*n + 1
%o A025586         if not n in l:
%o A025586             l+=[n, ]
%o A025586             if n<2: break
%o A025586         else: break
%o A025586     return max(l)
%o A025586 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Apr 14 2017
%o A025586 (Scala) def collatz(n: Int): Int = (n % 2) match {
%o A025586   case 0 => n / 2
%o A025586   case 1 => 3 * n + 1
%o A025586 }
%o A025586 def collatzTrajectory(start: Int): List[Int] = if (start == 1) List(1)
%o A025586 else {
%o A025586   import scala.collection.mutable.ListBuffer
%o A025586   var curr = start; var trajectory = new ListBuffer[Int]()
%o A025586   while (curr > 1) { trajectory += curr; curr = collatz(curr) }
%o A025586   trajectory.toList
%o A025586 }
%o A025586 for (n <- 1 to 100) yield collatzTrajectory(n).max // _Alonso del Arte_, Jun 02 2019
%Y A025586 Essentially the same as A056959: only a(1) and a(2) differ, see Comments.
%Y A025586 Cf. A006370, A006577, A006884, A006885, A220237.
%K A025586 nonn,nice,look
%O A025586 1,2
%A A025586 _David W. Wilson_