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.

A070165 Irregular triangle read by rows giving trajectory of n in Collatz problem.

Original entry on oeis.org

1, 2, 1, 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, 5, 16, 8, 4, 2, 1, 6, 3, 10, 5, 16, 8, 4, 2, 1, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 8, 4, 2, 1, 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, 11, 34, 17, 52, 26, 13
Offset: 1

Views

Author

Eric W. Weisstein, Apr 23 2002

Keywords

Comments

n-th row has A008908(n) entries (unless some n never reaches 1, in which case the triangle ends with an infinite row). [Escape clause added by N. J. A. Sloane, Jun 06 2017]
A216059(n) is the smallest number not occurring in n-th row; see also A216022.
Comment on the mp3 file from Gordon Charlton (the recording artist Beat Frequency). The piece uses the first 3242 terms (i.e. the first 100 hailstone sequences), with pitch modulus 36, duration modulus 2. Its musicality stems from the many repetitions and symmetries within the sequence, and in particular the infrequency of multiples of 3. This means that when the pitch modulus is a multiple of 12 the notes are predominantly in the symmetric octatonic scale, known to modern classical composers as the second of Messiaen's modes of limited transposition, and to jazz musicians as half-whole diminished. - N. J. A. Sloane, Jan 30 2019

Examples

			The irregular array a(n,k) starts:
n\k   0  1  2  3  4   5  6   7  8  9 10 11 12 13 14 15 16 17 18 19
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
11:  11 34 17 52 26  13 40  20 10  5 16  8  4  2  1
12:  12  6  3 10  5  16  8   4  2  1
13:  13 40 20 10  5  16  8   4  2  1
14:  14  7 22 11 34  17 52  26 13 40 20 10  5 16  8  4  2  1
15:  15 46 23 70 35 106 53 160 80 40 20 10  5 16  8  4  2  1
... Reformatted and extended by _Wolfdieter Lang_, Mar 20 2014
		

Crossrefs

Cf. A006370 (step), A008908 (row lengths), A033493 (row sums).
Cf. A220237 (sorted rows), A347270 (array), A192719.
Cf. A070168 (Terras triangle), A256598 (reduced triangle).
Cf. A254311, A257480 (and crossrefs therein).
Cf. A280408 (primes).

Programs

  • Haskell
    a070165 n k = a070165_tabf !! (n-1) !! (k-1)
    a070165_tabf = map a070165_row [1..]
    a070165_row n = (takeWhile (/= 1) $ iterate a006370 n) ++ [1]
    a070165_list = concat a070165_tabf
    -- Reinhard Zumkeller, Oct 07 2011
    
  • Maple
    T:= proc(n) option remember; `if`(n=1, 1,
          [n, T(`if`(n::even, n/2, 3*n+1))][])
        end:
    seq(T(n), n=1..15);  # Alois P. Heinz, Jan 29 2021
  • Mathematica
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; Flatten[Table[Collatz[n], {n, 10}]] (* T. D. Noe, Dec 03 2012 *)
  • PARI
    row(n, lim=0)={if (n==1, return([1])); my(c=n, e=0, L=List(n)); if(lim==0, e=1; lim=n*10^6); for(i=1, lim, if(c%2==0, c=c/2, c=3*c+1); listput(L, c); if(e&&c==1, break)); return(Vec(L)); } \\ Anatoly E. Voevudko, Mar 26 2016; edited by Michel Marcus, Aug 10 2021
    
  • Python
    def a(n):
        if n==1: return [1]
        l=[n, ]
        while True:
            if n%2==0: n/=2
            else: n = 3*n + 1
            if n not in l:
                l+=[n, ]
                if n<2: break
            else: break
        return l
    for n in range(1, 101): print(a(n)) # Indranil Ghosh, Apr 14 2017

Formula

T(n,k) = T^{(k)}(n) with the k-th iterate of the Collatz map T with T(n) = 3*n+1 if n is odd and T(n) = n/2 if n is even, n >= 1. T^{(0)}(n) = n. k = 0, 1, ..., A008908(n) - 1. - Wolfdieter Lang, Mar 20 2014

Extensions

Name specified and row length A-number corrected by Wolfdieter Lang, Mar 20 2014

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

A192719 Chain of Collatz sequences.

Original entry on oeis.org

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

Views

Author

Robert C. Lyons, Dec 31 2012

Keywords

Comments

The sequence is a chain of Collatz sequences. The first Collatz sequence in the chain is (1). Each of the subsequent Collatz sequences in the chain starts with the minimum positive integer that does not appear in the previous Collatz sequences. If the Collatz conjecture is true, then each Collatz sequence in the chain will end with 1, and the chain will include an infinite number of distinct Collatz sequences. If the Collatz conjecture is false, then the chain will end with the first Collatz sequence that does not converge to 1.
T(n,1) = A177729(n). - Reinhard Zumkeller, Jan 03 2013

Examples

			The first Collatz sequence in the chain is (1). The second Collatz sequence in the chain is (2, 1), which starts with 2, since 2 is the smallest positive integer that doesn't appear the first Collatz sequence. The third Collatz sequence in the chain is (3, 10, 5, 16, 8, 4, 2, 1), which starts with 3, since 3 is the smallest positive integer that doesn't appear the previous Collatz sequences.
Thus this irregular array starts:
1;
2,  1;
3, 10,  5, 16,  8,  4,  2,  1;
6,  3, 10,  5, 16,  8,  4,  2,  1;
7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10,  5, 16,  8, 4,  2, 1;
9, 28, 14,  7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1;
...
		

Crossrefs

Programs

  • Haskell
    a192719 n k = a192719_tabf !! (n-1) !! (k-1)
    a192719_row n = a192719_tabf !! (n-1)
    a192719_tabf = f [1..] where
       f (x:xs) = (a070165_row x) : f (del xs $ a220237_row x)
       del us [] = us
       del us'@(u:us) vs'@(v:vs) | u > v     = del us' vs
                                 | u < v     = u : del us vs'
                                 | otherwise = del us vs
    -- Reinhard Zumkeller, Jan 03 2013
  • Java
    See Lyons link.
    

A005184 Self-contained numbers: odd numbers k whose Collatz sequence contains a higher multiple of k.

Original entry on oeis.org

31, 83, 293, 347, 671, 19151, 2025797
Offset: 1

Views

Author

Keywords

Comments

The Collatz sequence of a number k is defined as a(1)=k, a(j+1) = a(j)/2 if a(j) is even, 3*a(j) + 1 if a(j) is odd.
No others less than 250000000. - Sam Handler (sam_5_5_5_0(AT)yahoo.com), Aug 07 2006
There are no more terms < 10^11. - Donovan Johnson, Nov 28 2013
There are no more terms < 10^15. - Alun Stokes, Mar 01 2021

Examples

			The Collatz sequence of 31 is 31, 94, 47, 142, 71, 214, 107, 322, 161, 484, 242, 121, 364, 182, 91, 274, 137, 412, 206, 103, 310 (see A008884) ... 310 is a multiple of 31, so the number 31 is "self-contained".
		

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

The ratios "higher multiple of k" / k are given in A059198.

Programs

  • Maple
    T:= proc(n) option remember; `if`(n=1, 1,
          [n, T(`if`(n::even, n/2, 3*n+1))][])
        end:
    q:= n-> ormap(x-> x>n and irem(x, n)=0, [T(n)]):
    select(q, [2*i-1$i=1..10000])[];  # Alois P. Heinz, Aug 04 2025
  • Mathematica
    isSelfContained[n_] := Module[{d}, d = n; While[d != 1, If[EvenQ[d], d = d/2, d = 3 * d + 1]; If[IntegerQ[d/n], Return[True]]]; Return[False]]; For[n = 1, n <= 250000000, n += 2, If[isSelfContained[n], Print[n]]]; (* Sam Handler (sam_5_5_5_0(AT)yahoo.com), Aug 07 2006 *)
    scnQ[n_] := MemberQ[Divisible[#, n] & / @Rest[NestWhileList[If[EvenQ[#], #/2, 3# + 1] &, n, # > 1 &]], True]; Select[Range[1, 2100001, 2], scnQ] (* Harvey P. Dale, Oct 21 2011 *)
  • PARI
    m=5; d=2; while(1,n=(3*m+1)\2; until(n==1,n=if(n%2,3*n+1,n\2); if(n%m==0,print(m," ",n); break)); m+=d; d=6-d)

Extensions

More terms from Robert G. Wilson v
Better description from Jack Brennen, Feb 07 2003

A246436 Number of numbers 1,...,n not occurring in the Collatz trajectory starting with n.

Original entry on oeis.org

0, 0, 0, 1, 1, 0, 2, 4, 2, 4, 4, 3, 6, 4, 8, 11, 8, 4, 8, 12, 15, 10, 14, 13, 11, 16, 17, 12, 15, 19, 21, 26, 16, 22, 26, 16, 19, 21, 21, 31, 28, 34, 23, 28, 31, 34, 34, 36, 29, 29, 33, 40, 43, 36, 40, 36, 33, 39, 37, 44, 47, 45, 48, 57, 42, 41, 45, 53, 56
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 01 2014

Keywords

Comments

a(n) = n - A159999(n).

Examples

			8-4-2-1: a(8) = #{3,5,6,7} = 4;
9-28-14-7-22-11-34-17-52-26-13-40-20-10-5-16-8-4-2-1: a(9) = #{3,6} = 2;
10-5-16-8-4-2-1: a(10) = #{3,6,7,9} = 4;
11-34-17-52-26-13-40-20-10-5-16-8-4-2-1: a(11) = #{3,6,7,9} = 4;
12-6-3-10-5-16-8-4-2-1: a(12) = #{7,9,11} = 3.
		

Crossrefs

Programs

  • Haskell
    import Data.List ((\\), genericIndex)
    a246436 n = length $ [1..n] \\ genericIndex a220237_tabf (n - 1)
  • Mathematica
    Table[Length[Complement[Range[n],NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]]],{n,70}] (* Harvey P. Dale, May 27 2018 *)

A225105 Odd numbers n such that the largest odd term in Collatz(3x+1) trajectory of n is prime.

Original entry on oeis.org

3, 5, 7, 9, 11, 13, 15, 17, 19, 23, 25, 29, 35, 37, 39, 53, 59, 61, 67, 75, 79, 87, 89, 99, 101, 105, 113, 115, 119, 131, 149, 153, 157, 173, 179, 181, 187, 197, 211, 219, 229, 241, 247, 249, 255, 267, 269, 277, 281, 307, 317, 329, 349, 371, 373, 383, 397
Offset: 1

Views

Author

Jayanta Basu, Apr 28 2013

Keywords

Examples

			15 is in the list since highest odd number in Collatz trajectory of 15 is 53, a prime.
		

Crossrefs

Programs

  • Haskell
    a225105 n = a225105_list !! (n-1)
    a225105_list = filter
       ((== 1) . a010051' . maximum . filter odd . a070165_row) a005408_list
    -- Reinhard Zumkeller, Apr 30 2013
  • Mathematica
    Coll[n_]:=NestWhileList[If[EvenQ[#],#/2,3*# + 1] &,n, #>1&];t={};Do[If[PrimeQ[Max[Select[Coll[n],OddQ]]],AppendTo[t,n]],{n,1,300,2}];t

A376079 a(n) is the largest difference of adjacent elements in the sorted list of the Collatz trajectory elements of n.

Original entry on oeis.org

1, 6, 2, 8, 6, 12, 4, 12, 6, 12, 4, 20, 12, 54, 8, 14, 12, 30, 6, 32, 12, 54, 8, 18, 14, 1944, 12, 36, 54, 1944, 16, 18, 12, 54, 12, 56, 30, 66, 20, 1944, 22, 48, 8, 68, 54, 1944, 24, 38, 18, 78, 14, 80, 1944, 1944, 12, 24, 30, 66, 54, 54, 1944, 1944, 32, 48, 12
Offset: 2

Views

Author

Markus Sigg, Sep 09 2024

Keywords

Comments

Trajectories end when they reach 1.

Examples

			The trajectory of 3 is (3,10,5,16,8,4,2,1), the sorted list of the trajectory elements is (1,2,3,4,5,8,10,16), the list of differences is (1,1,1,1,3,2,6) with maximum 6, so a(3) = 6.
		

Crossrefs

Cf. A220237 (sorted trajectory), A008908, A025586.

Programs

  • Mathematica
    Table[Max[Differences[Sort[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]]]],{n,2,70}] (* Harvey P. Dale, Aug 24 2025 *)
  • PARI
    a(n) = my(L = List([n])); while(n > 1, n = if(n % 2 == 0, n/2, 3*n + 1); listput(L, n)); listsort(L); vecmax(vector(#L - 1, i, L[i+1] - L[i]));
Showing 1-7 of 7 results.