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

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

Original entry on oeis.org

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

Views

Author

Keywords

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

Examples

			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.
		

Crossrefs

Essentially the same as A056959: only a(1) and a(2) differ, see Comments.

Programs

  • Haskell
    a025586 = last . a220237_row
    -- Reinhard Zumkeller, Jan 03 2013, Aug 29 2012
    
  • 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 *)
  • 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
    
  • 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

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 *)

A087232 a(n) is the largest odd term in the 3x+1 trajectory initiated at n.

Original entry on oeis.org

1, 1, 5, 1, 5, 5, 17, 1, 17, 5, 17, 5, 13, 17, 53, 1, 17, 17, 29, 5, 21, 17, 53, 5, 29, 13, 3077, 17, 29, 53, 3077, 1, 33, 17, 53, 17, 37, 29, 101, 5, 3077, 21, 65, 17, 45, 53, 3077, 5, 49, 29, 77, 13, 53, 3077, 3077, 17, 65, 29, 101, 53, 61, 3077, 3077, 1, 65, 33, 101, 17, 69
Offset: 1

Views

Author

Labos Elemer, Sep 18 2003

Keywords

Comments

a(n)=3077 corresponds to peak=9232.

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=1, 1, max(
         `if`(n::odd, n, 0), a(`if`(n::even, n/2, 3*n+1))))
        end:
    seq(a(n), n=1..88);  # Alois P. Heinz, Nov 14 2021
  • Mathematica
    c[x_] := (1-Mod[x, 2])*(x/2)+Mod[x, 2]*(3*x+1); c[1]=1; fpl[x_] := Delete[FixedPointList[c, x], -1] ofp[x_] := Part[fpl[x], Flatten[Position[OddQ[fpl[x]], True]]] Table[Max[ofp[w]], {w, 1, 256}]
    (* Second program: *)
    Array[Max@ Select[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, #, Unequal[#, 1, -1, -10, -34] &, 1, 10^4], OddQ] &, 69] (* Michael De Vlieger, May 15 2017, after Alonso del Arte at A025586 *)

Formula

If n = 2^k (for integers k >= 0), a(n) = 1; otherwise a(n) = (A025586(n)-1)/3 =(A056959(n)-1)/3. - Paolo Xausa, Nov 13 2021

Extensions

Name simplified by Paolo Xausa, Nov 13 2021

A352907 Records in the number of iterations in the 3x+1 sequences required to reach a power of 2.

Original entry on oeis.org

0, 3, 4, 12, 15, 16, 19, 107, 108, 111, 114, 117, 120, 123, 126, 139, 140, 166, 174, 177, 178, 204, 212, 233, 257, 263, 271, 274, 277, 303, 306, 319, 335, 346, 349, 370, 378, 381, 438, 444, 465, 504, 520, 523, 526, 552, 555, 558, 579, 592, 608, 660, 681, 684
Offset: 1

Views

Author

Omar E. Pol, Apr 07 2022

Keywords

Comments

Records of the number of nonpowers of 2 in the sequences 3x+1.
Is this a finite sequence?

Crossrefs

Records in A208981.
Cf. A352939 (first differences).
Cf. A347270 (gives all 3x+1 sequences).

Programs

  • Mathematica
    f[n_] := -1 + Length @ NestWhileList[If[OddQ[#], 3*# + 1, #/2] &, n, !IntegerQ @ Log[2, #] &]; Union @ FoldList[Max, Array[f, 10^5]] (* Amiram Eldar, Apr 08 2022 *)

Extensions

More terms from Alois P. Heinz, Apr 07 2022

A352939 First differences of the records in the number of iterations of the 3x+1 sequences required to reach a power of 2.

Original entry on oeis.org

3, 1, 8, 3, 1, 3, 88, 1, 3, 3, 3, 3, 3, 3, 13, 1, 26, 8, 3, 1, 26, 8, 21, 24, 6, 8, 3, 3, 26, 3, 13, 16, 11, 3, 21, 8, 3, 57, 6, 21, 39, 16, 3, 3, 26, 3, 3, 21, 13, 16, 52, 21, 3, 3, 13, 1, 39, 205, 1, 3, 3, 8, 1, 21, 1, 13, 8, 42, 37, 44, 1, 21, 31, 26, 3, 6, 1, 8, 6, 8, 13, 52, 1, 13, 3, 8, 3, 13, 8, 52, 3, 26, 3
Offset: 1

Views

Author

Omar E. Pol, Apr 07 2022

Keywords

Comments

First differences of the records in the number of nonpowers of 2 in the sequences 3x+1.
Is this a finite sequence?
Closely related to A288493 (perhaps the same after initial terms). - R. J. Mathar, May 20 2022

Examples

			The first 10 terms of A208981 are 0, 0, 3, 0, 1, 4, 12, 0, 15, 2. The records are 0, 3, 4, 12, 15. The first differences of these records are 3, 1, 8, 3, the same as the first four terms of this sequence.
		

Crossrefs

First differences of A352907.
Cf. A347270 (gives all 3x+1 sequences).

Programs

  • Mathematica
    f[n_] := -1 + Length @ NestWhileList[If[OddQ[#], 3*# + 1, #/2] &, n, ! IntegerQ @ Log[2, #] &]; Differences @ Union @ FoldList[Max, Array[f, 10^5]] (* Amiram Eldar, Apr 08 2022 *)

Extensions

More terms from Paolo Xausa, Jun 22 2022

A056957 In repeated iterations of function m->m/2 if m even, m->3m-1 if m odd, a(n) is minimum value achieved if starting from n.

Original entry on oeis.org

1, 1, 1, 1, 5, 1, 5, 1, 5, 5, 1, 1, 5, 5, 1, 1, 17, 5, 5, 5, 17, 1, 17, 1, 17, 5, 5, 5, 1, 1, 17, 1, 17, 17, 5, 5, 17, 5, 1, 5, 17, 17, 1, 1, 17, 17, 5, 1, 17, 17, 5, 5, 1, 5, 17, 5, 1, 1, 1, 1, 17, 17, 5, 1, 1, 17, 17, 17, 1, 5, 1, 5, 17, 17, 5, 5, 1, 1, 1, 5, 5, 17, 17, 17, 1, 1, 1, 1, 5, 17
Offset: 1

Views

Author

Henry Bottomley, Jul 18 2000

Keywords

Comments

At least for n<10000, the only possible cycles reached include 1,2,1,..., 5,14,7,20,10,5,... and 17,50,25,74,37,110,55,164,82,41,122,61,182,91,272,136,68,34,17,... For n<5 only the first occurs, while for n<17 only the first two occur.

Examples

			a(9)=5 since iteration starts: 9, 26, 13, 38, 19, 56, 28, 14, 7, 20, 10, 5, 14, 7, 20, 10, 5, ... and 5 is the smallest value
		

Crossrefs

Cf. A001281. If n is in A039500 then a(n)=1, if n is in A039501 then a(n)=5, if n is in A039502 then a(n)=17. If n is negative then this becomes the 3x+1 problem and the minimum values become those which are most negative (i.e. maximum absolute values) as in A056959.

Formula

a(2n) = a(n)

Extensions

Edited by Bryce Herdt (mathidentity(AT)yahoo.com), Apr 18 2010

A087262 Integer quotient of largest and initial values in 3x+1 iteration, started at n.

Original entry on oeis.org

1, 1, 5, 1, 3, 2, 7, 1, 5, 1, 4, 1, 3, 3, 10, 1, 3, 2, 4, 1, 3, 2, 6, 1, 3, 1, 341, 1, 3, 5, 297, 1, 3, 1, 4, 1, 3, 2, 7, 1, 225, 1, 4, 1, 3, 3, 196, 1, 3, 1, 4, 1, 3, 170, 167, 1, 3, 1, 5, 2, 3, 148, 146, 1, 3, 1, 4, 1, 3, 2, 130, 1, 126, 1, 4, 1, 3, 3, 10, 1, 3, 112, 111, 1, 3, 2, 6, 1, 3, 1, 101
Offset: 1

Views

Author

Labos Elemer, Sep 11 2003

Keywords

Comments

Remarkably often, several consecutive terms are identical or close, showing closeness of peaks too: at n=107-111, a(n)=83-86.
If a(n)=1, then the peak is the start-value (per A166245).
It is conjectured that if peak/initial value is an integer then it equals 1.

Crossrefs

Cf. A025586, A056959, A166245 (indices of 1's).

Programs

  • Mathematica
    c[x_] := (1-Mod[x, 2])*(x/2)+Mod[x, 2]*(3*x+1)c[1]=1; fpl[x_] := Delete[FixedPointList[c, x], -1] Table[Floor[Max[fpl[w]]/w//N], {w, 1, 256}]

Formula

a(n) = floor(A025586(n)/n).

A347271 Irregular triangle T(n,k) read by rows in which row n lists the terms of the 3x+1 trajectory of n, but the row ends when a term is a power of 2 or when a term is less than n, with n >= 1 and k >= 0.

Original entry on oeis.org

1, 2, 3, 10, 5, 16, 4, 5, 16, 6, 3, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 8, 9, 28, 14, 7, 10, 5, 11, 34, 17, 52, 26, 13, 40, 20, 10, 12, 6, 13, 40, 20, 10, 14, 7, 15, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 16, 17, 52, 26, 13, 18, 9, 19, 58, 29, 88, 44, 22, 11
Offset: 1

Views

Author

Omar E. Pol, Aug 25 2021

Keywords

Comments

Note that every row ends when it is easy to know the next missing terms because they are powers of 2 or the last term and the next missing terms form a row that it is already in the sequence.
For a square array with infinitely many terms in every row, see A347270, which is a supersequence that contains all 3x+1 sequences.

Examples

			Triangle begins:
   1;
   2;
   3,  10,   5,  16;
   4;
   5,  16;
   6,   3;
   7,  22,  11,  34,  17,  52,  26,  13,  40,  20,  10,   5;
   8;
   9,  28,  14,   7;
  10,   5;
  11,  34,  17,  52,  26,  13,  40,  20,  10;
  12,   6;
  13,  40,  20,  10;
  14,   7;
  15,  46,  23,  70,  35, 106,  53, 160,  80,  40,  20,  10;
  16;
  17,  52,  26,  13;
  18,   9;
  19,  58,  29,  88,  44,  22,  11;
...
For n = 3 the 3x+1 trajectory is 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, ... The fourth term is 16 which is a power of 2 so the third row of the triangle is [3, 10, 5, 16].
For n = 6 the 3x+1 trajectory is 6, 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, ... The second term is 3 which is less than 6 so the 6th row of the triangle is [6, 3].
		

Crossrefs

Subsequence of A070165, of A235795 and of A347270.

A341362 a(n) begins the first sequence of n consecutive positive integers with the same h-value and the same d-value in the Collatz (or '3x + 1') problem.

Original entry on oeis.org

1, 54, 108, 290, 290, 386, 172146, 298200, 596400, 596400, 596400, 795201, 795201, 2849196, 2849196, 8965036, 33659819, 45529226, 52417676, 93186987, 104161282, 104161282, 104161282, 436089218, 436089218, 605581697, 934358530, 934358530, 934358530, 3826876112
Offset: 1

Views

Author

Lamine Ngom, Feb 10 2021

Keywords

Comments

The Collatz function is as follows: F(x) = x/2 if x is even, otherwise F(x) = 3*x+1.
It is conjectured that starting from any number, and repeatedly applying the function on its previous result, we will always reach 1.
The d-value (or flight duration, A006577) is the number of steps needed to reach 1. The h-value (or flight height, A025586) is the maximum of the number's trajectory.

Examples

			a(3) = 108 because 108, 109 and 110 have same d-value (113) and same h-value (9232).
And 108 is the smallest number starting such sequence of 3 consecutive positive integers with same d-value and same h-value.
		

Crossrefs

Cf. A078441, A277109, A268253, A006577 (duration), A025586 (height), A056959.

A347264 Largest value in the 3x+1 sequence starting at n, divided by 4.

Original entry on oeis.org

1, 1, 4, 1, 4, 4, 13, 2, 13, 4, 13, 4, 10, 13, 40, 4, 13, 13, 22, 5, 16, 13, 40, 6, 22, 10, 2308, 13, 22, 40, 2308, 8, 25, 13, 40, 13, 28, 22, 76, 10, 2308, 16, 49, 13, 34, 40, 2308, 12, 37, 22, 58, 13, 40, 2308, 2308, 14, 49, 22, 76, 40, 46, 2308, 2308, 16, 49, 25
Offset: 1

Views

Author

Omar E. Pol, Aug 27 2021

Keywords

Comments

a(n) is the largest value in the n-th row of A347270 divided by 4.

Examples

			For n = 1 the 3x+1 sequence starting in 1 is 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, ... The largest value is 4 and 4/4 = 1 so a(1) = 1.
For n = 7 the 3x+1 sequence starting in 7 is 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, ... The largest value is 52 and 52/4 = 13 so a(7) = 13.
		

Crossrefs

[1, 1] together with A328147 (essentially the same sequence).

Formula

a(n) = A056959(n)/4.
Showing 1-10 of 10 results.