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

 


A025586
Largest value in '3x+1' trajectory of n.
59
1, 2, 16, 4, 16, 16, 52, 8, 52, 16, 52, 16, 40, 52, 160, 16, 52, 52, 88, 20, 64, 52, 160, 24, 88, 40, 9232, 52, 88, 160, 9232, 32, 100, 52, 160, 52, 112, 88, 304, 40, 9232, 64, 196, 52, 136, 160, 9232, 48, 148, 88, 232, 52, 160, 9232, 9232, 56, 196, 88, 304, 160, 184, 9232
OFFSET
1,2
COMMENTS
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.
a(n) = A220237(n,A006577(n)). - Reinhard Zumkeller, Jan 03 2013
A006885 and A006884 give record values and where they occur. - Reinhard Zumkeller, May 11 2013
For n > 2, a(n) is divisible by 4. See the explanatory comment in A056959. - Peter Munn, Oct 14 2019
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
EXAMPLE
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.
MAPLE
a:= proc(n) option remember; `if`(n=1, 1,
max(n, a(`if`(n::even, n/2, 3*n+1))))
end:
seq(a(n), n=1..87); # Alois P. Heinz, Oct 16 2021
MATHEMATICA
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 *)
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 *)
(* Using Weisstein's collatz[n] definition above *) Table[Max[collatz[n]], {n, 100}] (* Alonso del Arte, May 25 2019 *)
PROG
(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
(Haskell)
a025586 = last . a220237_row
-- Reinhard Zumkeller, Jan 03 2013, Aug 29 2012
(Python)
def a(n):
if n<2: return 1
l=[n, ]
while True:
if n%2==0: n//=2
else: n = 3*n + 1
if not n in l:
l+=[n, ]
if n<2: break
else: break
return max(l)
print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Apr 14 2017
(Scala) def collatz(n: Int): Int = (n % 2) match {
case 0 => n / 2
case 1 => 3 * n + 1
}
def collatzTrajectory(start: Int): List[Int] = if (start == 1) List(1)
else {
import scala.collection.mutable.ListBuffer
var curr = start; var trajectory = new ListBuffer[Int]()
while (curr > 1) { trajectory += curr; curr = collatz(curr) }
trajectory.toList
}
for (n <- 1 to 100) yield collatzTrajectory(n).max // Alonso del Arte, Jun 02 2019
CROSSREFS
Essentially the same as A056959: only a(1) and a(2) differ, see Comments.
Sequence in context: A110009 A232503 A348007 * A087251 A336833 A211367
KEYWORD
nonn,nice,look
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | 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 September 19 23:07 EDT 2024. Contains 376015 sequences. (Running on oeis4.)