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 121 results. Next

A355187 Number of Collatz trajectories (A070165) for all positive integers <= 10^n that contain 2^4 as the greatest power of 2 within its trajectory.

Original entry on oeis.org

6, 89, 933, 9401, 93744, 937712, 9379078, 93773848
Offset: 1

Views

Author

Frank M Jackson, Jun 23 2022

Keywords

Comments

It is conjectured that lim_{n->infinity} a(n)/10^n = 15/16. Empirically, 93.75% of all trajectories have 2^4 as the greatest power of 2 within its trajectory. Sequence A135282(n) is the maximum power of 2 reached in the Collatz trajectory for integer n.

Examples

			a(1)=6 because the first 10 positive integers have trajectories, of which 6 have 2^4 as the greatest power of 2 in their trajectory.
These integers are 3, 5, 6, 7, 9, 10. See trajectory tables below.
  1:    1
  2:    2  1
  3:    3 10  5 16  8   4  2   1
  4:    4  2  1
  5:    5 16  8  4  2   1
  6:    6  3 10  5 16   8  4   2  1
  7:    7 22 11 34 17  52 26  13 40 20 10  5 16  8  4  2  1
  8:    8  4  2  1
  9:    9 28 14  7 22  11 34  17 52 26 13 40 20 10  5 16  8  4  2  1
  10:  10  5 16  8  4   2  1
		

Crossrefs

Programs

  • Mathematica
    collatz[n_] := Module[{}, If[OddQ[n], 3n+1, n/2]]; step[n_] := Module[{p=0, m=n, q}, While[!IntegerQ[q=Log[2, m]], m=collatz[m]; p++]; {p, q}]; Counts[Table[Last@step[n], {n, 1, 10^5}]][[Key[4]]]

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

A006370 The Collatz or 3x+1 map: a(n) = n/2 if n is even, 3n + 1 if n is odd.

Original entry on oeis.org

0, 4, 1, 10, 2, 16, 3, 22, 4, 28, 5, 34, 6, 40, 7, 46, 8, 52, 9, 58, 10, 64, 11, 70, 12, 76, 13, 82, 14, 88, 15, 94, 16, 100, 17, 106, 18, 112, 19, 118, 20, 124, 21, 130, 22, 136, 23, 142, 24, 148, 25, 154, 26, 160, 27, 166, 28, 172, 29, 178, 30, 184, 31, 190, 32, 196, 33
Offset: 0

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 an unsolved problem. It is conjectured that the answer is yes.
The Krasikov-Lagarias paper shows that at least N^0.84 of the positive numbers < N fall into the 4-2-1 cycle of the 3x+1 problem. This is far short of what we think is true, that all positive numbers fall into this cycle, but it is a step. - Richard C. Schroeppel, May 01 2002
Also A001477 and A016957 interleaved. - Omar E. Pol, Jan 16 2014, updated Nov 07 2017
a(n) is the image of a(2*n) under the 3*x+1 map. - L. Edson Jeffery, Aug 17 2014
The positions of powers of 2 in this sequence are given in A160967. - Federico Provvedi, Oct 06 2021
If displayed as a rectangular array with six columns, the columns are A008585, A350521, A016777, A082286, A016789, A350522 (see example). - Omar E. Pol, Jan 03 2022

Examples

			G.f. = 4*x + x^2 + 10*x^3 + 2*x^4 + 16*x^5 + 3*x^6 + 22*x^7 + 4*x^8 + 28*x^9 + ...
From _Omar E. Pol_, Jan 03 2022: (Start)
Written as a rectangular array with six columns read by rows the sequence begins:
   0,   4,  1,  10,  2,  16;
   3,  22,  4,  28,  5,  34;
   6,  40,  7,  46,  8,  52;
   9,  58, 10,  64, 11,  70;
  12,  76, 13,  82, 14,  88;
  15,  94, 16, 100, 17, 106;
  18, 112, 19, 118, 20, 124;
  21, 130, 22, 136, 23, 142;
  24, 148, 25, 154, 26, 160;
  27, 166, 28, 172, 29, 178;
  30, 184, 31, 190, 32, 196;
...
(End)
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, E16.
  • J. C. Lagarias, ed., The Ultimate Challenge: The 3x+1 Problem, Amer. Math. Soc., 2010.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

A006577 gives number of steps to reach 1.
Column k=1 of A347270, n >= 1.

Programs

  • Haskell
    a006370 n | m /= 0    = 3 * n + 1
              | otherwise = n' where (n',m) = divMod n 2
    -- Reinhard Zumkeller, Oct 07 2011
    
  • Magma
    [(1/4)*(7*n+2-(-1)^n*(5*n+2)): n in [1..70]]; // Vincenzo Librandi, Dec 20 2016
  • Maple
    f := n-> if n mod 2 = 0 then n/2 else 3*n+1; fi;
    A006370:=(4+z+2*z**2)/(z-1)**2/(1+z)**2; # Simon Plouffe in his 1992 dissertation; uses offset 0
  • Mathematica
    f[n_]:=If[EvenQ[n],n/2,3n+1];Table[f[n],{n,50}] (* Geoffrey Critzer, Jun 29 2013 *)
    LinearRecurrence[{0,2,0,-1},{4,1,10,2},70] (* Harvey P. Dale, Jul 19 2016 *)
  • PARI
    for(n=1,100,print1((1/4)*(7*n+2-(-1)^n*(5*n+2)),","))
    
  • PARI
    A006370(n)=if(n%2,3*n+1,n/2) \\ Michael B. Porter, May 29 2010
    
  • Python
    def A006370(n):
        q, r = divmod(n, 2)
        return 3*n+1 if r else q # Chai Wah Wu, Jan 04 2015
    

Formula

G.f.: (4*x+x^2+2*x^3) / (1-x^2)^2.
a(n) = (1/4)*(7*n+2-(-1)^n*(5*n+2)). - Benoit Cloitre, May 12 2002
a(n) = ((n mod 2)*2 + 1)*n/(2 - (n mod 2)) + (n mod 2). - Reinhard Zumkeller, Sep 12 2002
a(n) = A014682(n+1) * A000034(n). - R. J. Mathar, Mar 09 2009
a(n) = a(a(2*n)) = -A001281(-n) for all n in Z. - Michael Somos, Nov 10 2016
E.g.f.: (2 + x)*sinh(x)/2 + 3*x*cosh(x). - Ilya Gutkovskiy, Dec 20 2016
From Federico Provvedi, Aug 17 2021: (Start)
Dirichlet g.f.: (1-2^(-s))*zeta(s) + (3-5*2^(-s))*zeta(s-1).
a(n) = ( a(n+2k) + a(n-2k) ) / 2, for every integer k. (End)
a(n) + a(n+1) = A047374(n+1). - Leo Ortega, Aug 22 2025

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001
Zero prepended and new Name from N. J. A. Sloane at the suggestion of M. F. Hasler, Nov 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 *)

A008908 a(n) = (1 + number of halving and tripling steps to reach 1 in the Collatz (3x+1) problem), or -1 if 1 is never reached.

Original entry on oeis.org

1, 2, 8, 3, 6, 9, 17, 4, 20, 7, 15, 10, 10, 18, 18, 5, 13, 21, 21, 8, 8, 16, 16, 11, 24, 11, 112, 19, 19, 19, 107, 6, 27, 14, 14, 22, 22, 22, 35, 9, 110, 9, 30, 17, 17, 17, 105, 12, 25, 25, 25, 12, 12, 113, 113, 20, 33, 20, 33, 20, 20, 108, 108, 7, 28, 28, 28, 15, 15, 15, 103
Offset: 1

Views

Author

Keywords

Comments

The number of steps (iterations of the map A006370) to reach 1 is given by A006577, this sequence counts 1 more. - M. F. Hasler, Nov 05 2017
When Collatz 3N+1 function is seen as an isometry over the dyadics, the halving step necessarily following each tripling is not counted, hence N -> N/2, if even, but N -> (3N+1)/2, if odd. Counting iterations of this map until reaching 1 leads to sequence A064433. - Michael Vielhaber (vielhaber(AT)gmail.com), Nov 18 2009

References

  • R. K. Guy, Unsolved Problems in Number Theory, E16.

Crossrefs

Programs

  • Haskell
    a008908 = length . a070165_row
    -- Reinhard Zumkeller, May 11 2013, Aug 30 2012, Jul 19 2011
    
  • Maple
    a:= proc(n) option remember; 1+`if`(n=1, 0,
          a(`if`(n::even, n/2, 3*n+1)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Jan 29 2021
  • Mathematica
    Table[Length[NestWhileList[If[EvenQ[ # ], #/2, 3 # + 1] &, i, # != 1 &]], {i, 75}]
  • PARI
    a(n)=my(c=1); while(n>1, n=if(n%2, 3*n+1, n/2); c++); c \\ Charles R Greathouse IV, May 18 2015
    
  • Python
    def a(n):
        if n==1: return 1
        x=1
        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, Apr 15 2017

Formula

a(n) = A006577(n) + 1.
a(n) = f(n,1) with f(n,x) = if n=1 then x else f(A006370(n),x+1).
a(A033496(n)) = A159999(A033496(n)). - Reinhard Zumkeller, May 04 2009
a(n) = A006666(n) + A078719(n).
a(n) = length of n-th row in A070165. - Reinhard Zumkeller, May 11 2013

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
Edited by M. F. Hasler, Nov 05 2017

A033493 Sum of the numbers in the trajectory of n for the 3x+1 problem.

Original entry on oeis.org

1, 3, 49, 7, 36, 55, 288, 15, 339, 46, 259, 67, 119, 302, 694, 31, 214, 357, 519, 66, 148, 281, 633, 91, 658, 145, 101440, 330, 442, 724, 101104, 63, 841, 248, 540, 393, 535, 557, 2344, 106, 101331, 190, 1338, 325, 497, 679, 100979, 139, 806, 708, 1130, 197
Offset: 1

Views

Author

Keywords

Comments

Given a power of two, the value in this sequence is the next higher Mersenne number, or a(2^m) = 2^(m + 1) - 1. - Alonso del Arte, Apr 10 2009
Conjecture: a(n) = A006577(n)^2 only at a(3) = 49. Verified for n <= 10^7. - Luca Santarsiero, Jul 13 2025

Examples

			a(5) = 36 because the Ulam's conjecture trajectory sequence starting on 5 runs 5, 16, 8, 4, 2, 1 and therefore 5 + 16 + 8 + 4 + 2 + 1 = 36. - _Alonso del Arte_, Apr 10 2009
		

Crossrefs

Apart from initial term, exactly the same as A049074.

Programs

  • Haskell
    a033493 = sum . a070165_row  -- Reinhard Zumkeller, Oct 08 2011
    
  • Maple
    a:= proc(n) option remember; n+`if`(n=1, 0,
          a(`if`(n::even, n/2, 3*n+1)))
        end:
    seq(a(n), n=1..55);  # Alois P. Heinz, Jan 29 2021
  • Mathematica
    collatz[1] = 1; collatz[n_Integer?OddQ] := 3n + 1; collatz[n_Integer?EvenQ] := n/2; Table[-1 + Plus @@ FixedPointList[collatz, n], {n, 60}] (* Alonso del Arte, Apr 10 2009 *)
  • Python
    def a(n):
        if n==1: return 1
        l=[n, ]
        while True:
            if n%2==0: n//=2
            else: n = 3*n + 1
            l+=[n, ]
            if n<2: break
        return sum(l)
    print([a(n) for n in range(1, 101)])  # Indranil Ghosh, Apr 14 2017

Formula

a(n) = Sum_{k=1..A006577(n)} A070165(k). - Reinhard Zumkeller, Oct 08 2011

Extensions

Corrected a(16) to 31 to match other powers of 2; removed duplicate value of a(48) = 139 because a(49) = 806 and not 139. - Alonso del Arte, Apr 10 2009

A061641 Pure numbers in the Collatz (3x+1) iteration. Also called pure hailstone numbers.

Original entry on oeis.org

0, 1, 3, 6, 7, 9, 12, 15, 18, 19, 21, 24, 25, 27, 30, 33, 36, 37, 39, 42, 43, 45, 48, 51, 54, 55, 57, 60, 63, 66, 69, 72, 73, 75, 78, 79, 81, 84, 87, 90, 93, 96, 97, 99, 102, 105, 108, 109, 111, 114, 115, 117, 120, 123, 126, 127, 129, 132, 133, 135, 138, 141, 144, 145
Offset: 1

Views

Author

Frederick Magata (frederick.magata(AT)uni-muenster.de), Jun 14 2001

Keywords

Comments

Let {f(k,N), k=0,1,2,...} denote the (3x+1)-sequence with starting value N; a(n) denotes the smallest positive integer which is not contained in the union of f(k,0),...,f(k,a(n-1)).
In other words, a(n) is the starting value of the next '3x+1'-sequences in the sense that a(n) is not a value in any sequence f(k,N) with N < a(n).
f(0,N)=N, f(k+1,N)=f(k,N)/2 if f(k,N) is even and f(k+1,N)=3*f(k,N)+1 if f(k,N) is odd.
For all n, a(n) mod 6 is 0, 1 or 3. I conjecture that a(n)/n -> C=constant for n->oo, where C=2.311...
The Collatz conjecture says that for all positive n, there exists k such that C_k(n) = 1. Shaw states [p. 195] that "A positive integer n is pure if its entire tree of preimages under the Collatz function C are greater than or equal to it; otherwise n is impure. Equivalently, a positive integer n is impure if there exists rGary W. Adamson, Jan 28 2007
Pure numbers remaining after deleting the impure numbers in the hailstone (Collatz) problem; where the operation C(n) = {3n+1, n odd; n/2, n even}. Add the 0 mod 3 terms in order, among the terms of A127633, since all 0 mod 3 numbers are pure. - Gary W. Adamson, Jan 28 2007
After computing all a(n) < 10^9, the ratio a(n)/n appears to be converging to 2.31303... Hence it appears that the numbers in this sequence have a density of about 1/3 (due to all multiples of 3) + 99/1000. - T. D. Noe, Oct 12 2007
A016945 is a subsequence. - Reinhard Zumkeller, Apr 17 2008

Examples

			Consider n=3: C(n), C_2(n), C_3(n), ...; the iterates are 10, 5, 16, 8, 4, 2, 1, 4, 2, 1; where 4, 5, 8, 10 and 16 have appeared in the orbit of 3 and are thus impure.
a(1)=1 since Im(f(k,0))={0} for all k and so 1 is not a value of f(k,0). a(2)=3 since Im(f(k,0)) union Im(f(k,1))={0,1,2,4} and 3 is the smallest positive integer not contained in this set.
		

Crossrefs

Cf. A070165 (Collatz trajectories), A127633, A336938, A336938. See A177729 for a variant.

Programs

  • Mathematica
    DoCollatz[n_] := Module[{m = n}, While[m > nn || ! reached[[m]], If[m <= nn, reached[[m]] = True]; If[EvenQ[m], m = m/2, m = 3 m + 1]]]; nn = 200; reached = Table[False, {nn}]; t = {0, 1}; While[DoCollatz[t[[-1]]]; pos = Position[reached, False, 1, 1]; pos != {}, AppendTo[t, pos[[1, 1]]]]; t (* T. D. Noe, Jan 22 2013 *)
  • PARI
    firstMiss(A) = { my(i); if(#A == 0 || A[1] > 0, return(0)); for(i = 1, A[#A] + 1, if(!setsearch(A,i), return(i))); };
    iter(A) = { my(a = firstMiss(A)); while(!setsearch(A,a), A = setunion(A, Set([a])); a = if(a % 2, 3*a+1, a/2)); A; };
    makeVec(m) = { my(v = [], A = Set([]), i); for(i = 1, m, v = concat(v, firstMiss(A)); if (i < m, A = iter(A))); v; };
    makeVec(64) \\ Markus Sigg, Aug 08 2020

Extensions

Edited by T. D. Noe and N. J. A. Sloane, Oct 16 2007

A033496 Numbers m that are the largest number in their Collatz (3x+1) trajectory.

Original entry on oeis.org

1, 2, 4, 8, 16, 20, 24, 32, 40, 48, 52, 56, 64, 68, 72, 80, 84, 88, 96, 100, 104, 112, 116, 128, 132, 136, 144, 148, 152, 160, 168, 176, 180, 184, 192, 196, 200, 208, 212, 224, 228, 232, 240, 244, 256, 260, 264, 272, 276, 280, 288, 296, 304, 308, 312, 320, 324
Offset: 1

Views

Author

Keywords

Comments

Or, possible peak values in 3x+1 trajectories: 1,2 and m=16k+4,16k+8,16k but not for all k; those 4k numbers [like m=16k+12 and others] which cannot be such peaks are listed in A087252.
Possible values of A025586(m) in increasing order. See A275109 (number of times each value of a(n) occurs in A025586). - Jaroslav Krizek, Jul 17 2016

Examples

			These peak values occur in 1, 3, 6, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 27, 30, 39, 44, 71, 75, 1579 [3x+1]-iteration trajectories started with different initial values. This list most probably is incomplete.
From _Hartmut F. W. Hoft_, Jun 24 2016: (Start)
Let n be the maximum in some Collatz trajectory and let F(n), the initial fan of n, be the set of all initial values less than or equal to n whose Collatz trajectories lead to n as their maximum. Then the size of F(n) never equals 2, 4, 5, 7 or 10 (see the link).
Conjecture: Every number k > 10 occurs as the size of F(n) for some n.
Fans F(n) of size k, for all 10 < k < 355, exist for 4 <= n <= 50,000,000. The largest fan in this range, F(41163712), has size 7450.
(End)
		

Crossrefs

Cf. A095384 (contains a definition of Collatz[]).

Programs

  • Haskell
    a033496 n = a033496_list !! (n-1)
    a033496_list = 1 : filter f [2, 4 ..] where
       f x = x == maximum (takeWhile (/= 1) $ iterate a006370 x)
    -- Reinhard Zumkeller, Oct 22 2015
    
  • Magma
    Set(Sort([Max([k eq 1 select n else IsOdd(Self(k-1)) and not IsOne(Self(k-1)) select 3*Self(k-1)+1 else Self(k-1) div 2: k in [1..5*n]]): n in [1..2^10] | Max([k eq 1 select n else IsOdd(Self(k-1)) and not IsOne(Self(k-1)) select 3*Self(k-1)+1 else Self(k-1) div 2: k in [1..5*n]]) le 2^10])) // Jaroslav Krizek, Jul 17 2016
    
  • 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 *)
    Select[Range[324], Max[Collatz[#]] == # &] (* T. D. Noe, Feb 28 2013 *)
  • 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 n not in l:
                l.append(n)
                if n<2: break
            else: break
        return l
    print([n for n in range(1, 501) if max(a(n)) == n]) # Indranil Ghosh, Apr 14 2017

Formula

A008908(a(n)) = A159999(a(n)). - Reinhard Zumkeller, May 04 2009
Max(A070165(a(n),k): k=1..A008908(a(n))) = A070165(a(n),1) = a(n). - Reinhard Zumkeller, Oct 22 2015

A070168 Irregular triangle of Terras-modified Collatz problem.

Original entry on oeis.org

1, 2, 1, 3, 5, 8, 4, 2, 1, 4, 2, 1, 5, 8, 4, 2, 1, 6, 3, 5, 8, 4, 2, 1, 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2, 1, 8, 4, 2, 1, 9, 14, 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2, 1, 10, 5, 8, 4, 2, 1, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2, 1, 12, 6, 3, 5, 8, 4, 2, 1, 13, 20, 10, 5, 8, 4, 2, 1, 14, 7, 11
Offset: 1

Views

Author

Eric W. Weisstein, Apr 23 2002

Keywords

Comments

The row length of this irregular triangle is A006666(n) + 1 = A064433(n+1), n >= 1. - Wolfdieter Lang, Mar 20 2014

Examples

			The irregular triangle begins:
n\k   0   1   2   3   4   5   6   8  9 10  11  12  13  14 ...
1:    1
2:    2   1
3:    3   5   8   4   2   1
4:    4   2   1
5:    5   8   4   2   1
6:    6   3   5   8   4   2   1
7:    7  11  17  26  13  20  10   5  8  4   2   1
8:    8   4   2   1
9:    9  14   7  11  17  26  13  20 10  5   8   4   2   1
10:  10   5   8   4   2   1
11:  11  17  26  13  20  10   5   8  4  2   1
12:  12   6   3   5   8   4   2   1
13:  13  20  10   5   8   4   2   1
14:  14   7  11  17  26  13  20  10  5  8   4   2   1
15:  15  23  35  53  80  40  20  10  5  8   4   2   1
...  formatted by _Wolfdieter Lang_, Mar 20 2014
-------------------------------------------------------------
		

Crossrefs

Cf. A070165 (ordinary Collatz case).
Cf. A014682, A248573, A285098 (row sums).

Programs

  • Haskell
    a070168 n k = a070168_tabf !! (n-1) !! (k-1)
    a070168_tabf = map a070168_row [1..]
    a070168_row n = (takeWhile (/= 1) $ iterate a014682 n) ++ [1]
    a070168_list = concat a070168_tabf
    -- Reinhard Zumkeller, Oct 03 2014
    
  • Mathematica
    f[n_] := If[EvenQ[n], n/2, (3 n + 1)/2];
    Table[NestWhileList[f, n, # != 1 &], {n, 1, 30}] // Grid (* Geoffrey Critzer, Oct 18 2014 *)
  • Python
    def a(n):
        if n==1: return [1]
        l=[n, ]
        while True:
            if n%2==0: n//=2
            else: n = (3*n + 1)//2
            l.append(n)
            if n<2: break
        return l
    for n in range(1, 16): print(a(n)) # Indranil Ghosh, Apr 15 2017

Formula

From Wolfdieter Lang, Mar 20 2014: (Start)
See Lagarias, pp. 4-7, eqs. (2.1), (2.4) with (2.5) and (2.6).
T(n,k) = T^{(k)}(n), with the iterations of the Terras-modified Collatz map: T(n) = n/2 if n is even and otherwise (3*n+1)/2, n >= 1. T^{(0)}(n) = n.
T(n,k) = lambda(n,k)*n + rho(n,k), with lambda(n,k) = (3^X(n,k,-1))/2^k and rho(n,k) = sum(x(n,j)*(3^X(n,k,j))/ 2^(k-j), j=0..(k-1)) with X(n,k,j) = sum(x(n,j+p), p=1.. (k-1-j)) where x(n,j) = T^{(j)}(n) (mod 2). The parity sequence suffices to determine T(n,k).
(End)

Extensions

Name shortened, tabl changed into tabf, Cf. added by Wolfdieter Lang, Mar 20 2014

A256598 Irregular triangle where row n contains the odd terms in the Collatz sequence beginning with 2n+1.

Original entry on oeis.org

1, 3, 5, 1, 5, 1, 7, 11, 17, 13, 5, 1, 9, 7, 11, 17, 13, 5, 1, 11, 17, 13, 5, 1, 13, 5, 1, 15, 23, 35, 53, 5, 1, 17, 13, 5, 1, 19, 29, 11, 17, 13, 5, 1, 21, 1, 23, 35, 53, 5, 1, 25, 19, 29, 11, 17, 13, 5, 1, 27, 41, 31, 47, 71, 107, 161, 121, 91, 137, 103, 155
Offset: 0

Views

Author

Bob Selcoe, Apr 03 2015

Keywords

Comments

The Collatz function is an integer-valued function given by n/2 if n is even and 3n+1 if n is odd. We build a Collatz sequence by beginning with a natural number and iterating the function indefinitely. It is conjectured that all such sequences terminate at 1.
In this triangle, row n is made up of the odd terms of the Collatz sequence beginning with 2n+1. Therefore, it is conjectured that this sequence is well-defined, i.e., that all rows terminate at 1.
The last index k in row n gives the number of iterations required for the Collatz sequence to terminate if even terms are omitted.
T(n,k)/T(n,k+1) is of form: ceiling(T(n,k)*3/2^j) for some j>=1. Therefore, the coefficients in each row may be read as a series of iterated ceilings, where j may vary. For example, row 3 has initial term 7, which is followed by ceiling(7*3/2), ceiling(ceiling(7*3/2)*3/2), ceiling(ceiling(ceiling(7*3/2)*3/2)*3/4), ceiling(ceiling(ceiling(ceiling(7*3/2)*3/2)*3/4)*3/8), ceiling(ceiling(ceiling(ceiling(ceiling(7*3/2)*3/2)*3/4)*3/8)*3/16).
The length of row n is A258145(n) (set to 0 if 1 is not reached after a finite number of steps). - Wolfdieter Lang, Aug 11 2021

Examples

			Triangle starts T(0,0):
n\k   0   1   2   3   4    5   6   7   8   9  10 ...
0:    1
1:    3   5   1
2:    5   1
3:    7   11  17  13  5    1
4:    9   7   11  17  13   5   1
5:    11  17  13  5   1
6:    13  5   1
7:    15  23  35  53  5    1
8:    17  13  5   1
9:    19  29  11  17  13   5   1
10:   21  1
11:   23  35  53  5    1
12:   25  19  29  11  17  13   5   1
...
n=13 starts with 27 and takes 41 steps: (27), 41, 31, 47, 71, 107,... 53, 5, 1, (see A372443).
Row 8 is [17, 13, 5, 1] because it is the subsequence of odd terms for the Collatz sequence starting with 17: [17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1].
		

Crossrefs

Cf. A372443 (row 13 up to its first 1).
Cf. also array A372283 showing the same terms in different orientation.

Programs

  • Mathematica
    f[n_] := NestWhileList[(3*# + 1)/2^IntegerExponent[3*# + 1, 2] &, 2*n + 1, # > 1 &]; Grid[Table[f[n], {n, 0, 12}]] (* L. Edson Jeffery, Apr 25 2015 *)
  • PARI
    row(n) = {my(oddn = 2*n+1, vl = List(oddn), x); while (oddn != 1, x = 3*oddn+1; oddn = x >> valuation(x, 2); listput(vl, oddn)); Vec(vl);}
    tabf(nn) = {for (n=0, nn, my(rown = row(n)); for (k=1, #rown, print1(rown[k], ", ")); print;);} \\ Michel Marcus, Oct 04 2019
  • Sage
    def Collatz(n):
        A = [n]
        b = A[-1]
        while b != 1:
            if is_even(b):
                A.append(b//2)
            else:
                A.append(3*b+1)
        return A
    [y for sublist in [[x for x in Collatz(2*n+1) if is_odd(x)] for n in [0..15]] for y in sublist] # Tom Edgar, Apr 04 2015
    

Formula

T(n,0) = 2n+1 and T(n,k) = A000265(3*T(n,k-1)+1) for k>0. - Tom Edgar, Apr 04 2015
Showing 1-10 of 121 results. Next