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.

Showing 1-10 of 12 results. Next

A006577 Number of halving and tripling steps to reach 1 in '3x+1' problem, or -1 if 1 is never reached.

Original entry on oeis.org

0, 1, 7, 2, 5, 8, 16, 3, 19, 6, 14, 9, 9, 17, 17, 4, 12, 20, 20, 7, 7, 15, 15, 10, 23, 10, 111, 18, 18, 18, 106, 5, 26, 13, 13, 21, 21, 21, 34, 8, 109, 8, 29, 16, 16, 16, 104, 11, 24, 24, 24, 11, 11, 112, 112, 19, 32, 19, 32, 19, 19, 107, 107, 6, 27, 27, 27, 14, 14, 14, 102, 22
Offset: 1

Views

Author

Keywords

Comments

The 3x+1 or Collatz problem is as follows: start with any number n. If n is even, divide it by 2, otherwise multiply it by 3 and add 1. Do we always reach 1? This is a famous unsolved problem. It is conjectured that the answer is yes.
It seems that about half of the terms satisfy a(i) = a(i+1). For example, up to 10000000, 4964705 terms satisfy this condition.
n is an element of row a(n) in triangle A127824. - Reinhard Zumkeller, Oct 03 2012
The number of terms that satisfy a(i) = a(i+1) for i being a power of ten from 10^1 through 10^10 are: 0, 31, 365, 4161, 45022, 477245, 4964705, 51242281, 526051204, 5378743993. - John Mason, Mar 02 2018
5 seems to be the only number whose value matches its total number of steps (checked to n <= 10^9). - Peter Woodward, Feb 15 2021

Examples

			a(5)=5 because the trajectory of 5 is (5,16,8,4,2,1).
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, E16.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

See A070165 for triangle giving trajectories of n = 1, 2, 3, ....

Programs

  • Haskell
    import Data.List (findIndex)
    import Data.Maybe (fromJust)
    a006577 n = fromJust $ findIndex (n `elem`) a127824_tabf
    -- Reinhard Zumkeller, Oct 04 2012, Aug 30 2012
    
  • Maple
    A006577 := proc(n)
            local a,traj ;
            a := 0 ;
            traj := n ;
            while traj > 1 do
                    if type(traj,'even') then
                            traj := traj/2 ;
                    else
                            traj := 3*traj+1 ;
                    end if;
                    a := a+1 ;
            end do:
            return a;
    end proc: # R. J. Mathar, Jul 08 2012
  • Mathematica
    f[n_] := Module[{a=n,k=0}, While[a!=1, k++; If[EvenQ[a], a=a/2, a=a*3+1]]; k]; Table[f[n],{n,4!}] (* Vladimir Joseph Stephan Orlovsky, Jan 08 2011 *)
    Table[Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#!=1&]]-1,{n,80}] (* Harvey P. Dale, May 21 2012 *)
  • PARI
    a(n)=if(n<0,0,s=n; c=0; while(s>1,s=if(s%2,3*s+1,s/2); c++); c)
    
  • PARI
    step(n)=if(n%2,3*n+1,n/2);
    A006577(n)=if(n==1,0,A006577(step(n))+1); \\ Michael B. Porter, Jun 05 2010
    
  • Python
    def a(n):
        if n==1: return 0
        x=0
        while True:
            if n%2==0: n//=2
            else: n = 3*n + 1
            x+=1
            if n<2: break
        return x
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 05 2017
    
  • Python
    def A006577(n):
        ct = 0
        while n != 1: n = A006370(n); ct += 1
        return ct # Ya-Ping Lu, Feb 22 2024
    
  • R
    collatz<-function(n) ifelse(n==1,0,1+ifelse(n%%2==0,collatz(n/2),collatz(3*n+1))); sapply(1:72, collatz) # Christian N. K. Anderson, Oct 09 2024

Formula

a(n) = A006666(n) + A006667(n).
a(n) = A112695(n) + 2 for n > 2. - Reinhard Zumkeller, Apr 18 2008
a(n) = A008908(n) - 1. - L. Edson Jeffery, Jul 21 2014
a(n) = A135282(n) + A208981(n) (after Alonso del Arte's comment in A208981), if 1 is reached, otherwise a(n) = -1. - Omar E. Pol, Apr 10 2022
a(n) = 2*A007814(n + 1) + a(A085062(n)) + 1 for n > 1. - Wing-Yin Tang, Jan 06 2025

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001
"Escape clause" added to definition by N. J. A. Sloane, Jun 06 2017

A347270 Square array T(n,k) in which row n lists the 3x+1 sequence starting at n, read by antidiagonals upwards, with n >= 1 and k >= 0.

Original entry on oeis.org

1, 2, 4, 3, 1, 2, 4, 10, 4, 1, 5, 2, 5, 2, 4, 6, 16, 1, 16, 1, 2, 7, 3, 8, 4, 8, 4, 1, 8, 22, 10, 4, 2, 4, 2, 4, 9, 4, 11, 5, 2, 1, 2, 1, 2, 10, 28, 2, 34, 16, 1, 4, 1, 4, 1, 11, 5, 14, 1, 17, 8, 4, 2, 4, 2, 4, 12, 34, 16, 7, 4, 52, 4, 2, 1, 2, 1, 2, 13, 6, 17, 8, 22
Offset: 1

Views

Author

Omar E. Pol, Aug 25 2021

Keywords

Comments

This array gives all 3x+1 sequences.
The 3x+1 or Collatz problem is described in A006370.
Column k gives the image of n at the k-th step.
This infinite square array contains the irregular triangles A070165, A235795 and A347271.
For a piping diagram of the 3x+1 problem see A235800.

Examples

			The corner of the square array begins:
   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, ...
   3,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, ...
   5,16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, ...
   6, 3,10, 5,16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, ...
   7,22,11,34,17,52,26,13,40,20,10, 5,16, 8, 4, 2, 1, 4, 2, 1, ...
   8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, ...
   9,28,14, 7,22,11,34,17,52,26,13,40,20,10, 5,16, 8, 4, 2, 1, ...
  10, 5,16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, ...
  11,34,17,52,26,13,40,20,10, 5,16, 8, 4, 2, 1, 4, 2, 1, 4, 2, ...
  12, 6, 3,10, 5,16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, ...
  13,40,20,10, 5,16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, ...
  14, 7,22,11,34,17,52,26,13,40,20,10, 5,16, 8, 4, 2, 1, 4, 2, ...
...
		

Crossrefs

Main diagonal gives A347272.
Parity of this sequence is A347283.
Largest value in row n gives A056959.
Number of nonpowers of 2 in row n gives A208981.
Some rows n are: A153727 (n=1), A033478 (n=3), A033479 (n=9), A033480 (n=15), A033481 (n=21), A008884 (n=27), A008880 (n=33), A008878 (n=39), A008883 (n=51), A008877 (n=57), A008874 (n=63), A258056 (n=75), A258098 (n=79), A008876 (n=81), A008879 (n=87), A008875 (n=95), A008873 (n=97), A008882 (n=99), A245671 (n=1729).
First four columns k are: A000027 (k=0), A006370 (k=1), A075884 (k=2), A076536 (k=3).

Programs

  • Maple
    T:= proc(n, k) option remember; `if`(k=0, n, (j->
          `if`(j::even, j/2, 3*j+1))(T(n, k-1)))
        end:
    seq(seq(T(d-k, k), k=0..d-1), d=1..20);  # Alois P. Heinz, Aug 25 2021
  • Mathematica
    T[n_, k_] := T[n, k] = If[k == 0, n, Function[j,
         If[EvenQ[j], j/2, 3*j + 1]][T[n, k - 1]]];
    Table[Table[T[d - k, k], {k, 0, d - 1}], {d, 1, 20}] // Flatten (* Jean-François Alcover, Mar 02 2022, after Alois P. Heinz *)

A208981 Number of iterations required to reach a power of 2 in the 3x+1 sequence starting at n.

Original entry on oeis.org

0, 0, 3, 0, 1, 4, 12, 0, 15, 2, 10, 5, 5, 13, 13, 0, 8, 16, 16, 3, 1, 11, 11, 6, 19, 6, 107, 14, 14, 14, 102, 0, 22, 9, 9, 17, 17, 17, 30, 4, 105, 2, 25, 12, 12, 12, 100, 7, 20, 20, 20, 7, 7, 108, 108, 15, 28, 15, 28, 15, 15, 103, 103, 0, 23, 23, 23, 10, 10, 10
Offset: 1

Views

Author

L. Edson Jeffery, Mar 04 2012

Keywords

Comments

The original name was: Number of iterations of the Collatz recursion required to reach a power of 2.
The statement that all paths must eventually reach a power of 2 is equivalent to the Collatz conjecture.
A006577(n) - a(n) gives the exponent for the first power of 2 reached in the Collatz trajectory of n. - Alonso del Arte, Mar 05 2012
Number of nonpowers of 2 in the 3x+1 sequence starting at n. - Omar E. Pol, Sep 05 2021

Examples

			a(7) = 12 because the Collatz trajectory for 7 is 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, ... which reached 16 = 2^4 in 12 steps.
		

Crossrefs

Row sums of A347519.
Cf. A006577 (and references therein).
Cf. A347270 (gives all 3x+1 sequences).

Programs

  • Haskell
    a208981 = length . takeWhile ((== 0) . a209229) . a070165_row
    -- Reinhard Zumkeller, Jan 02 2013
    
  • Maple
    a:= proc(n) option remember; `if`(n=2^ilog2(n), 0,
          1+a(`if`(n::odd, 3*n+1, n/2)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Sep 05 2021
  • Mathematica
    Collatz[n_?OddQ] := 3*n + 1; Collatz[n_?EvenQ] := n/2; Table[-1 + Length[NestWhileList[Collatz, n, Not[IntegerQ[Log[2, #]]] &]], {n, 50}] (* Alonso del Arte, Mar 04 2012 *)
  • PARI
    ispow2(n)=n>>=valuation(n,2); n==1
    a(n)=my(s); while(!ispow2(n), n=if(n%2, 3*n+1, n/2); s++); s \\ Charles R Greathouse IV, Jul 31 2016

Formula

For x>0 an integer, define f_0(x)=x, and for r=1,2,..., f_r(x)=f_{r-1}(x)/2 if f_{r-1}(x) is even, else f_r(x)=3*f_{r-1}(x)+1. Then a(n) = min(k such that f_k(n) is equal to a power of 2).
a(n) = A006577(n) - A135282(n) (after Alonso del Arte's comment), if A006577(n) is not -1. - Omar E. Pol, Apr 10 2022

Extensions

Name clarified by Omar E. Pol, Apr 10 2022

A232503 Largest power of 2 in the Collatz (3x+1) trajectory of n.

Original entry on oeis.org

1, 2, 16, 4, 16, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 64, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 16, 16, 16, 16, 16, 16, 16, 16, 16, 64, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 64, 16, 16, 16, 16
Offset: 1

Views

Author

Lance Luttrell, Nov 24 2013

Keywords

Comments

All terms are powers of 4 (A000302) unless n is an odd-indexed power of 2 (A004171), as explained in one of the comments for A135282. - Alonso del Arte, Nov 26 2013

Examples

			a(8) = 8 because then there are only halving steps and thus 8 is the largest power of 2 in its Collatz trajectory.
a(9) = 16 because the Collatz sequence for 9 goes 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 (see A033479) and the largest power of 2 there is 16.
		

Crossrefs

Programs

  • Mathematica
    Collatz[n_?OddQ] := 3n + 1; Collatz[n_?EvenQ] := n/2; Table[NestWhile[Collatz, n, Not[IntegerQ[Log[2, #]]] &], {n, 64}] (* Alonso del Arte, Nov 26 2013 based on T. D. Noe's program for A135282 *)
    Table[With[{p2=2^Range[0,10]},Select[NestWhileList[If[EvenQ[#], #/2, 3#+1]&, n,#>1&], MemberQ[ p2,#]&]]//Max,{n,70}] (* Harvey P. Dale, May 07 2016 *)
  • Scheme
    (define (A232503 n) (let loop ((n n) (m 1)) (if (= 1 n) m (loop (A006370 n) (if (= 1 (A209229 n)) (max n m) m)))))
    (define (A006370 n) (if (even? n) (/ n 2) (+ 1 n n n)))
    ;; Antti Karttunen, Aug 18 2017

Formula

a(n) = 2^A135282(n). - Antti Karttunen, Aug 18 2017

A347409 Longest run of halving steps in the trajectory from n to 1 in the Collatz map (or 3x+1 problem), or -1 if no such trajectory exists.

Original entry on oeis.org

0, 1, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 6, 4, 5, 4, 4, 4, 5, 4, 4, 5, 5, 5, 4, 4, 5, 4, 4, 4, 4, 4, 5, 6, 4, 4, 4, 5, 5, 4, 4, 4, 4, 4, 5, 5, 5, 4, 4, 4, 4, 5, 5, 5, 5, 6, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 8, 4, 4, 4, 4, 4, 5, 5, 5, 6, 8, 4, 4
Offset: 1

Views

Author

Paolo Xausa, Aug 30 2021

Keywords

Comments

If the longest run of halving steps occurs as the final part of the trajectory, a(n) = A135282(n), otherwise a(n) > A135282(n).
Every nonnegative integer appears in the sequence at least once, since for any k >= 0 a(2^k) = k.
Conjecture: every integer >= 4 appears in the sequence infinitely many times.

Examples

			a(15) = 5 because the Collatz trajectory starting at 15 contains, as the longest halving run, a 5-step subtrajectory (namely, 160 -> 80 -> 40 -> 20 -> 10 -> 5).
		

Crossrefs

Cf. A347668 (indices of records), A347669 (indices of first occurrences), A348007.

Programs

  • Mathematica
    nterms=100;Table[c=n;sm=0;While[c>1,If[OddQ[c],c=3c+1,If[(s=IntegerExponent[c,2])>sm,sm=s];c/=2^s]];sm,{n,nterms}]
  • PARI
    a(n)=my(nb=0); while (n != 1, if (n % 2, n=3*n+1, my(x = valuation(n, 2)); n /= 2^x; nb = max(nb, x));); nb; \\ Michel Marcus, Sep 03 2021
    
  • Python
    def A347409(n):
        m, r = n, 0
        while m > 1:
            if m % 2:
                m = 3*m + 1
            else:
                s = bin(m)[2:]
                c = len(s)-len(s.rstrip('0'))
                m //= 2**c
                r = max(r,c)
        return r # Chai Wah Wu, Sep 29 2021

A347668 Indices of records in A347409.

Original entry on oeis.org

1, 2, 3, 15, 21, 75, 151, 1365, 5461, 7407, 14563, 87381, 184111, 932067, 5592405, 13256071, 26512143, 357913941, 1431655765, 3817748707, 22906492245, 91625968981, 244335917283, 1466015503701, 5212499568715, 10424999137431, 93824992236885
Offset: 1

Views

Author

Paolo Xausa, Sep 10 2021

Keywords

Comments

Conjecture 1: A347409(a(n)) is even for n >= 11. Conjecture 2: all even numbers > 2 appear as A347409(a(n)) for some n. - Chai Wah Wu, Sep 29 2021
If conjectures 1 and 2 are true, then A347409(a(n)) = 2n - 6 for n >= 11, and hence a(n) <= (4^(n-3)-1)/3 for n >= 11 since A347409((4^(n-3)-1)/3) = 2n - 6. - Charles R Greathouse IV, Oct 25 2022

Crossrefs

Programs

  • Mathematica
    A347409[n_]:=(c=n;sm=0;While[c>1,If[OddQ[c],c=3c+1,If[(s=IntegerExponent[c,2])>sm,sm=s];c/=2^s]];sm)
    upto=100000;a={};rec=-1;Do[If[(r=A347409[i])>rec,rec=r;AppendTo[a,i]],{i,upto}];a
  • PARI
    f(n)=my(nb=0); while (n != 1, if (n % 2, n=3*n+1, my(x = valuation(n, 2)); n /= 2^x; nb = max(nb, x)); ); nb; \\ A347409
    lista(nn) = my(r=-1, m); for (n=1, nn, if ((m=f(n)) > r, print1(n, ", "); r = m);); \\ Michel Marcus, Sep 10 2021

Extensions

a(15) from Michel Marcus, Sep 10 2021
a(16)-a(17) from Alois P. Heinz, Sep 10 2021
a(18)-a(20) from Michael S. Branicky, Sep 28 2021
a(21)-a(22) from Michael S. Branicky, Sep 30 2021
a(23) from Michael S. Branicky, Oct 04 2021
a(24)-a(27) from Kevin P. Thompson, Apr 14 2022

A226123 Number of terms of the form 2^k in Collatz(3x+1) trajectory of n.

Original entry on oeis.org

1, 2, 5, 3, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5, 5, 5, 5, 5, 5, 5, 7, 9, 5, 5
Offset: 1

Views

Author

Jayanta Basu, May 27 2013

Keywords

Comments

a(n) = sum(A209229(A070165(n,k)): k=1..A006577(n)). - Reinhard Zumkeller, May 30 2013

Examples

			a(3)=5 since Collatz trajectory of 3 contains terms 1,2,4,8 and 16.
		

Crossrefs

Programs

  • Haskell
    a226123 = sum . map a209229 . a070165_row
    -- Reinhard Zumkeller, May 30 2013
  • Mathematica
    coll[n_]:=NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]; Table[Length[Select[coll[n],IntegerQ[Log[2,#]]&]],{n,87}]

A347532 a(n) is the sum of the nonpowers of 2 in the 3x+1 sequence that starts at n.

Original entry on oeis.org

0, 0, 18, 0, 5, 24, 257, 0, 308, 15, 228, 36, 88, 271, 663, 0, 183, 326, 488, 35, 21, 250, 602, 60, 627, 114, 101409, 299, 411, 693, 101073, 0, 810, 217, 509, 362, 504, 526, 2313, 75, 101300, 63, 1307, 294, 466, 648, 100948, 108, 775, 677, 1099, 166, 368, 101463, 102285, 355
Offset: 1

Views

Author

Omar E. Pol, Sep 05 2021

Keywords

Comments

a(n) is the sum of the nonpowers of 2 in the n-th row of A347270.
a(n) = 0 if and only if n is a power of 2.

Examples

			For n = 6 the 3x+1 sequence starting at 6 is 6, 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, ... Only the first four terms are nonpowers of 2. The sum of them is 6 + 3 + 10 + 5 = 24, so a(6) = 24.
		

Crossrefs

Cf. A208981 (number of nonpowers of 2).

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=2^ilog2(n), 0,
          n+a(`if`(n::odd, 3*n+1, n/2)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Sep 05 2021
  • Mathematica
    a[n_] := Plus @@ Select[NestWhileList[If[OddQ[#], 3*# + 1, #/2] &, n, # > 1 &], # != 2^IntegerExponent[#, 2] &]; Array[a, 50] (* Amiram Eldar, Sep 06 2021 *)

Formula

From Alois P. Heinz, Sep 05 2021: (Start)
a(n) = A033493(n) - 2 * A232503(n) + 1.
a(n) = A033493(n) - 2^(A135282(n)+1) + 1. (End)

A347669 Indices of first occurrences of n in A347409.

Original entry on oeis.org

1, 2, 4, 8, 3, 15, 21, 128, 75, 512, 151, 2048, 1365, 8192, 5461, 7407, 14563, 131072, 87381, 524288, 184111, 2097152, 932067, 6213783, 5592405, 33554432, 13256071, 134217728, 26512143, 530242875, 357913941, 1899273247, 1431655765, 8589934592, 3817748707, 34359738368
Offset: 0

Views

Author

Paolo Xausa, Sep 10 2021

Keywords

Examples

			a(5) = 15 because 5 occurs for the first time at position 15 in A347409.
		

Crossrefs

Programs

  • Mathematica
    A347409[n_]:=A347409[n]=(c=n;sm=0;While[c>1,If[OddQ[c],c=3c+1,If[(s=IntegerExponent[c,2])>sm,sm=s];c/=2^s]];sm)
    nterms=20;Table[i=0;While[A347409[++i]!=n];i,{n,0,nterms-1}]
  • PARI
    f(n) = {my(nb=0); while (n != 1, if (n % 2, n=3*n+1, my(x = valuation(n, 2)); n /= 2^x; nb = max(nb, x)); ); nb; } \\ A347409
    a(n) = my(k=1); while (f(k) != n, k++); k; \\ Michel Marcus, Sep 10 2021

Extensions

a(21)-a(22) from Michel Marcus, Sep 10 2021
a(23)-a(28) from Alois P. Heinz, Sep 11 2021
a(29)-a(34) from Michael S. Branicky, Sep 28 2021
a(35) from Chai Wah Wu, Oct 02 2021

A348007 Starting value of the longest run of halving steps in the trajectory from n to 1 in the Collatz map (or 3x+1 problem), or -1 if no such trajectory exists.

Original entry on oeis.org

2, 16, 4, 16, 16, 16, 8, 16, 16, 16, 16, 16, 16, 160, 16, 16, 16, 16, 16, 64, 16, 160, 16, 16, 16, 160, 16, 16, 160, 160, 32, 16, 16, 160, 16, 112, 16, 304, 16, 160, 64, 112, 16, 16, 160, 160, 48, 112, 16, 16, 16, 160, 160, 160, 16, 112, 16, 304, 160, 160, 160
Offset: 2

Views

Author

Paolo Xausa, Sep 24 2021

Keywords

Comments

In case of ties (two or more longest runs of same length), the highest starting value is picked. The first n for which the longest run of halving steps occurs at two different subtrajectories is 37, where the Collatz map contains the 4-step subtrajectories 112 -> 56 -> 28 -> 14 > 7 and 16 -> 8 -> 4 -> 2 -> 1. a(37) is therefore 112 (highest starting value).
If the Collatz conjecture (i.e., all trajectories reach 1) is true then, except for n = 2, 4 and 8, a(n) mod 16 = 0, since all trajectories contain (at least) 4 consecutive halvings.

Examples

			a(2) = 2 because the Collatz trajectory from 2 to 1 is simply 2 -> 1 (one halving step, starting at 2).
a(3) = 16 because the trajectory from 3 to 1 is 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1. Here, the longest halving run is the 4-step subtrajectory 16 -> 8 -> 4 -> 2 -> 1, which starts at 16.
a(15) = 160 because the longest halving run in the trajectory from 15 to 1 (the 5-step subtrajectory 160 -> 80 -> 40 -> 20 -> 10 -> 5) starts at 160.
		

Crossrefs

Programs

  • Mathematica
    nterms=100;Table[c=n;cm=sm=0;While[c>1,If[OddQ[c],c=3c+1,s=IntegerExponent[c,2];If[s>sm,sm=s;cm=c,If[s==sm,cm=Max[cm,c]]];c/=2^s]];cm,{n,2,nterms+1}]
  • PARI
    A348007(n) = { my(m2v=valuation(n,2), mx=n, t); while(n>1, if((t=valuation(n,2))>m2v, m2v=t; mx=n, if(t==m2v && n>mx, mx=n)); if(!(n%2),n/=2,n+=(n+n+1))); (mx); }; \\ Antti Karttunen, Oct 13 2021

Formula

a(2^k) = 2^k, for integers k >= 1.
a(n) mod 2^A347409(n) = 0.
Showing 1-10 of 12 results. Next