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-7 of 7 results.

A006667 Number of tripling steps to reach 1 from n in '3x+1' problem, or -1 if 1 is never reached.

Original entry on oeis.org

0, 0, 2, 0, 1, 2, 5, 0, 6, 1, 4, 2, 2, 5, 5, 0, 3, 6, 6, 1, 1, 4, 4, 2, 7, 2, 41, 5, 5, 5, 39, 0, 8, 3, 3, 6, 6, 6, 11, 1, 40, 1, 9, 4, 4, 4, 38, 2, 7, 7, 7, 2, 2, 41, 41, 5, 10, 5, 10, 5, 5, 39, 39, 0, 8, 8, 8, 3, 3, 3, 37, 6, 42, 6, 3, 6, 6, 11, 11, 1, 6, 40, 40, 1, 1, 9, 9, 4, 9, 4, 33, 4, 4, 38
Offset: 1

Views

Author

Keywords

Comments

A075680, which gives the values for odd n, isolates the essential behavior of this sequence. - T. D. Noe, Jun 01 2006
A033959 and A033958 give record values and where they occur. - Reinhard Zumkeller, Jan 08 2014

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 204, Problem 22.
  • 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

Equals A078719(n)-1.

Programs

  • Haskell
    a006667 = length . filter odd . takeWhile (> 2) . (iterate a006370)
    a006667_list = map a006667 [1..]
    -- Reinhard Zumkeller, Oct 08 2011
    
  • Maple
    a:= proc(n) option remember; `if`(n<2, 0,
          `if`(n::even, a(n/2), 1+a(3*n+1)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Aug 08 2023
  • Mathematica
    Table[Count[Differences[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]], ?Positive], {n,100}] (* _Harvey P. Dale, Nov 14 2011 *)
  • PARI
    for(n=2,100,s=n; t=0; while(s!=1,if(s%2==0,s=s/2,s=(3*s+1)/2; t++); if(s==1,print1(t,","); ); ))
    
  • 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, Apr 14 2017

Formula

a(1) = 0, a(n) = a(n/2) if n is even, a(n) = a(3n+1)+1 if n>1 is odd. The Collatz conjecture is that this defines a(n) for all n >= 1.
a(n) = A078719(n) - 1; a(A000079(n))=0; a(A062052(n))=1; a(A062053(n))=2; a(A062054(n))=3; a(A062055(n))=4; a(A062056(n))=5; a(A062057(n))=6; a(A062058(n))=7; a(A062059(n))=8; a(A062060(n))=9. - Reinhard Zumkeller, Oct 08 2011
a(n*2^k) = a(n), for all k >= 0. - L. Edson Jeffery, Aug 11 2014
a(n) = floor(log(2^A006666(n)/n)/log(3)). - Joe Slater, Aug 30 2017
a(n) = a(A085062(n)) + A007814(n+1) for n >= 2. - Alan Michael Gómez Calderón, Feb 07 2025
From Alan Michael Gómez Calderón, Mar 31 2025: (Start)
a(n) = a(A139391(n)) + (n mod 2) for n >= 2;
a(n) = a(A139391(A000265(n))) - A209229(n) + 1 for n >= 2;
a(n) = a(A000265(A139391(n))) + (n mod 2) for n >= 2. (End)

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

A198584 Odd numbers producing exactly 3 odd numbers in the Collatz (3x+1) iteration.

Original entry on oeis.org

3, 13, 53, 113, 213, 227, 453, 853, 909, 1813, 3413, 3637, 7253, 7281, 13653, 14549, 14563, 29013, 29125, 54613, 58197, 58253, 116053, 116501, 218453, 232789, 233013, 464213, 466005, 466033, 873813, 931157, 932053, 932067, 1856853, 1864021, 1864133
Offset: 1

Views

Author

T. D. Noe, Oct 28 2011

Keywords

Comments

One of the odd numbers is always 1. So besides a(n), there is exactly one other odd number, A198585(n), which is a term in A002450.
Sequences A228871 and A228872 show that there are two sequences here: the odd numbers in order and out of order. - T. D. Noe, Sep 12 2013
Start with the numbers in A350053. If k is in sequence then so is 4*k+1. - Ralf Stephan, Jun 18 2025

Examples

			The Collatz iteration of 113 is 113, 340, 170, 85, 256, 128, 64, 32, 16, 8, 4, 2, 1, which shows that 113, 85, and 1 are the three odd terms.
		

Crossrefs

Cf. A062053 (numbers producing 3 odds in their Collatz iteration).
Cf. A092893 (least number producing n odd numbers).
Cf. A198586-A198593 (odd numbers producing 2-10 odd numbers).

Programs

  • Mathematica
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; t = {}; Do[If[Length[Select[Collatz[n], OddQ]] == 3, AppendTo[t, n]], {n, 1, 10000, 2}]; t
  • Python
    # get n-th term in sequence
    def isqrt(n):
      i=0
      while(i*i<=n):
        i+=1
      return i-1
    for n in range (200):
      s = isqrt(3*n)//3
      a = s*3
      b = (a*a)//3
      c = n-b
      d = 4*(n*3+a+(c4*s+1)+(c>5*s+1))+5
      e = isqrt(d)
      f = e-1-( (d-e*e) >> 1 )
      r = ((((8<André Hallqvist, Jul 25 2019
    
  • Python
    # just prints the sequence
    for a in range (5,100,1):
      for b in range(a-8+4*(a&1),0,-6):
        print(( ((1<André Hallqvist, Aug 14 2019

Formula

Numbers of the form (2^m*(2^n-1)/3-1)/3 where n == 2 (mod 6) if m is even and n == 4 (mod 5) if m is odd. - Charles R Greathouse IV, Sep 09 2022
a(n) = (16*2^floor(b(n)) - 2^(2*floor((b(n) - 1)/2) + 3*floor(b(n)) - 6*(floor(b(n)/2) - floor((floor(b(n))^2 + 20)/12) + n) - 2))/9 - 1/3 where b(n) = sqrt(3)*sqrt(4*n - 3). - Alan Michael Gómez Calderón, Feb 02 2025

A354236 A(n,k) is the n-th number m such that the Collatz (or 3x+1) trajectory starting at m contains exactly k odd integers; square array A(n,k), n>=1, k>=1, read by antidiagonals.

Original entry on oeis.org

1, 5, 2, 3, 10, 4, 17, 6, 20, 8, 11, 34, 12, 21, 16, 7, 22, 35, 13, 40, 32, 9, 14, 23, 68, 24, 42, 64, 25, 18, 15, 44, 69, 26, 80, 128, 33, 49, 19, 28, 45, 70, 48, 84, 256, 43, 65, 50, 36, 29, 46, 75, 52, 85, 512, 57, 86, 66, 51, 37, 30, 88, 136, 53, 160, 1024
Offset: 1

Views

Author

Alois P. Heinz, May 20 2022

Keywords

Examples

			Square array A(n,k) begins:
    1,   5,  3,  17, 11,  7,  9,  25,  33,  43, ...
    2,  10,  6,  34, 22, 14, 18,  49,  65,  86, ...
    4,  20, 12,  35, 23, 15, 19,  50,  66,  87, ...
    8,  21, 13,  68, 44, 28, 36,  51,  67,  89, ...
   16,  40, 24,  69, 45, 29, 37,  98, 130, 172, ...
   32,  42, 26,  70, 46, 30, 38,  99, 131, 173, ...
   64,  80, 48,  75, 88, 56, 72, 100, 132, 174, ...
  128,  84, 52, 136, 90, 58, 74, 101, 133, 177, ...
  256,  85, 53, 138, 92, 60, 76, 102, 134, 178, ...
  512, 160, 96, 140, 93, 61, 77, 196, 260, 179, ...
		

Crossrefs

Row n=1 gives A092893(k-1).
Main diagonal gives A380244.

Programs

  • Maple
    b:= proc(n) option remember; irem(n, 2, 'r')+
          `if`(n=1, 0, b(`if`(n::odd, 3*n+1, r)))
        end:
    A:= proc() local h, p, q; p, q:= proc() [] end, 0;
          proc(n, k)
            if k=1 then return 2^(n-1) fi;
            while nops(p(k))
    				
  • Mathematica
    b[n_] := b[n] = Module[{q, r}, {q, r} = QuotientRemainder[n, 2]; r +
         If[n == 1, 0, b[If[OddQ[n], 3*n + 1, q]]]];
    A = Module[{h, p, q}, p[_] = {}; q = 0;
         Function[{n, k}, If[k == 1, 2^(n - 1)];
         While[Length[p[k]] < n, q = q + 1;
            h = b[q];
            p[h] = Append[p[h], q]];
         p[k][[n]]]];
    Table[Table[A[n, 1+d-n], {n, 1, d}], {d, 1, 12}] // Flatten (* Jean-François Alcover, Jun 02 2022, after Alois P. Heinz *)

Formula

A078719(A(n,k)) = k.

A062054 Numbers with 4 odd integers in their Collatz (or 3x+1) trajectory.

Original entry on oeis.org

17, 34, 35, 68, 69, 70, 75, 136, 138, 140, 141, 150, 151, 272, 276, 277, 280, 282, 300, 301, 302, 544, 552, 554, 560, 564, 565, 600, 602, 604, 605, 1088, 1104, 1108, 1109, 1120, 1128, 1130, 1137, 1200, 1204, 1205, 1208, 1210, 2176, 2208, 2216, 2218, 2240
Offset: 1

Views

Author

Keywords

Comments

The Collatz (or 3x+1) function is f(x) = x/2 if x is even, 3x+1 if x is odd.
The Collatz trajectory of n is obtained by applying f repeatedly to n until 1 is reached.
A078719(a(n)) = 4; A006667(a(n)) = 3.
Numbers m such that (s0 - 4s1)/2m = 1 where s0 is the sum of the even elements and s1 the sum of the odd elements in the Collatz trajectory of m. - Michel Lagneau, Aug 13 2018
If m is in the sequence then so is 2*m, so one would only have to check odd numbers. - David A. Corneth, Aug 13 2018

Examples

			The Collatz trajectory of 17 is (17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1), which contains 4 odd integers. - _Jeffrey R. Goodwin_, Oct 26 2011
		

References

  • J. Shallit and D. Wilson, The "3x+1" Problem and Finite Automata, Bulletin of the EATCS #46 (1992) pp. 182-185.

Crossrefs

Programs

Formula

The twelve formulas giving this sequence are listed in Corollary 3.3 in J. R. Goodwin with the following caveats: the value x cannot equal zero in formulas (3.16) and (3.20), one must multiply the formulas by all powers of 2 (2^1, 2^2, ...) to get the evens. - Jeffrey R. Goodwin, Oct 26 2011

A092892 Smallest starting value in a Collatz '3x+1' sequence such that the sequence contains exactly n halving steps.

Original entry on oeis.org

1, 2, 4, 8, 5, 3, 6, 12, 24, 17, 11, 7, 14, 9, 18, 36, 25, 49, 33, 65, 43, 86, 57, 39, 78, 153, 105, 203, 135, 270, 185, 123, 246, 169, 329, 219, 159, 295, 569, 379, 283, 505, 377, 251, 167, 111, 222, 444, 297, 593, 395, 263, 175, 350, 233, 155, 103, 206, 137, 91, 182
Offset: 0

Views

Author

Hugo Pfoertner, Mar 11 2004

Keywords

Comments

First occurrence of n in A006666.
The graph of this sequence has features similar to those of A092893, but with the x-axis scaled by log(3)/log(2). - T. D. Noe, Apr 09 2007

Examples

			a(5)=3 because the Collatz sequence 3,10,5,16,8,4,2,1 is the first sequence containing 5 halving steps.
		

Crossrefs

Programs

A330732 a(n) is the smallest number whose odd hailstone sequence has length n (including 1 and itself) and is in descending order.

Original entry on oeis.org

1, 5, 13, 17, 45, 241, 321, 1713, 9137, 24365, 36033, 173261, 231681, 630033, 1642769, 4380717, 11715629, 31241677, 41655569, 111081517, 148108689, 789913009, 1053217345, 1404289793, 3744772781, 9986060749, 13314747665, 35505993773, 94682650061, 128599099649
Offset: 1

Views

Author

Xiangyu Chen, Dec 28 2019

Keywords

Comments

The hailstone (Collatz) sequence of a number is defined by repeated operations of f(x), where f(x)=x/2 if x is even, and f(x)=3x+1 if x is odd. The odd numbers of a number's hailstone sequence are also called its odd hailstone sequence.
The odd hailstone sequence of 45 [45, 17, 13, 5, 1] contains the first five terms of this sequence.
Note that a(n+1) isn't necessarily greater than a(n).

Examples

			Consider a(8): [1713, 1285, 241, 181, 17, 13, 5, 1]; the odd hailstone sequence of 1713 is descending and has length 8. 1713 is the lowest such number.
		

Crossrefs

Programs

  • Mathematica
    With[{s = Array[If[AllTrue[Differences@ #, # < 0 &], Length@ #, 0] &@ Select[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, #, # > 1 &], OddQ] &, 10^5]}, Array[FirstPosition[s, #][[1]] &, Max@ s]] (* Michael De Vlieger, Jan 01 2020 *)
  • PARI
    is(k, n) = {my(x=k, v=List([])); while(x>1, if(x%2==0, x=x/2, listput(v, x); x=3*x+1)); 1+#v==n&&v==vecsort(v, , 4); }
    a(n) = {k=1; while(is(k, n)==0, k+=2); k; } \\ Jinyuan Wang, Dec 31 2019

Extensions

a(23)-a(30) from Kevin P. Thompson, Jul 23 2022

A375888 Rectangular array: row n shows all k such that n is the number of rises in the trajectory of k in the Collatz problem.

Original entry on oeis.org

1, 2, 5, 4, 10, 3, 8, 20, 6, 17, 16, 21, 12, 34, 11, 32, 40, 13, 35, 22, 7, 64, 42, 24, 68, 23, 14, 9, 128, 80, 26, 69, 44, 15, 18, 25, 256, 84, 48, 70, 45, 28, 19, 49, 33, 512, 85, 52, 75, 46, 29, 36, 50, 65, 43, 1024, 160, 53, 136, 88, 30, 37, 51, 66, 86, 57
Offset: 0

Views

Author

Clark Kimberling, Sep 11 2024

Keywords

Comments

Assuming that the Collatz conjecture (also known as the 3x+1 conjecture) is true, this is a permutation of the positive integers; viz., every positive integer occurs exactly once. Conjecture: every row contains a pair of consecutive integers.

Examples

			Corner:
   1     2     4     8    16    32    64   128   256   512  1024
   5    10    20    21    40    42    80    84    85   160   168
   3     6    12    13    24    26    48    52    53    96   104
  17    34    35    68    69    70    75   136   138   140   141
  11    22    23    44    45    46    88    90    92    93   176
   7    14    15    28    29    30    56    58    60    61   112
   9    18    19    36    37    38    72    74    76    77    81
6 is in row 2 because the trajectory, (6, 3, 10, 5, 16, 4, 2, 1), has exactly 2 rises: 3 to 10, and 5 to 16.
		

Crossrefs

Cf. A000027, A000079 (row 1), A092893 (column 1), A006667, A070265, A078719.
Cf. A354236.

Programs

  • Mathematica
    t = Table[Count[Differences[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]], ? Positive], {n, 2048}]; (* after _Harvey P. Dale, A006667 *)
    r[n_] := Flatten[Position[t, n - 1]];
    Column[Table[r[n], {n, 1, 21}]] (* array *)
    u = Table[r[k][[n + 1 - k]], {n, 1, 12}, {k, 1, n}]
    Flatten[u] (* sequence *)

Formula

Transpose of the array in A354236.
Showing 1-7 of 7 results.