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.

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

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

A076228 Number of terms k in the trajectory of the Collatz function applied to n such that k < n.

Original entry on oeis.org

0, 1, 2, 2, 3, 5, 4, 3, 6, 5, 6, 8, 6, 9, 6, 4, 8, 13, 10, 7, 5, 11, 8, 10, 13, 9, 9, 15, 13, 10, 9, 5, 16, 11, 8, 19, 17, 16, 17, 8, 12, 7, 19, 15, 13, 11, 12, 11, 19, 20, 17, 11, 9, 17, 14, 19, 23, 18, 21, 15, 13, 16, 14, 6, 22, 24, 21, 14, 12, 11, 15, 22, 18, 21, 7, 21, 19, 25, 22, 9
Offset: 1

Views

Author

Labos Elemer, Oct 01 2002

Keywords

Comments

It is believed that for each x, a(n) = x occurs a finite number of times and the largest n is 2^x.
Original name: Start iteration of Collatz-function (A006370) with initial value of n. a(n) shows how many times during fixed-point-list, the value sinks below initial one until reaching endpoint = 1. - Michael De Vlieger, Dec 13 2018

Examples

			A070165(18) = {18, 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1}. a(18) = 13 because 13 terms are smaller than n = 18; namely: {9, 14, 7, 11, 17, 13, 10, 5, 16, 8, 4, 2, 1}.
		

Crossrefs

Programs

  • Mathematica
    f[x_] := (1-Mod[x, 2])*(x/2)+(Mod[x, 2])*(3*x+1) f[1]=1; f0[x_] := Delete[FixedPointList[f, x], -1] f1[x_] := f0[x]-Part[f0[x], 1] f2[x_] := Count[Sign[f1[x]], -1] Table[f2[w], {w, 1, 256}]
    (* Second program: *)
    Table[Count[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, # > 1 &], ?(# < n &)], {n, 80}] (* _Michael De Vlieger, Dec 09 2018 *)

A160000 Number of partitions of n into parts occurring in '3x+1'-trajectory starting with n.

Original entry on oeis.org

1, 2, 3, 4, 5, 11, 9, 10, 17, 20, 23, 66, 35, 57, 51, 36, 77, 153, 122, 126, 61, 213, 189, 883, 353, 338, 337, 851, 645, 570, 571, 202, 1220, 1066, 901, 4017, 3462, 2440, 2777, 1598, 1852, 512, 8084, 4909, 3952, 3122, 3399, 29851, 17813, 11391, 11285, 7128
Offset: 1

Views

Author

Reinhard Zumkeller, May 11 2009

Keywords

Examples

			7-22-11-34-17-52-26-13-40-20-10-5-16-8-[4-2-1]*:
{1,2,4,5,7} is the set of numbers <= n, occurring in this trajectory, therefore a(7) = #{7, 5+2, 5+1+1, 4+2+1, 4+1+1+1, 2+2+2+1, 2+2+1+1+1, 2+1+1+1+1+1, 1+1+1+1+1+1+1} = 9.
		

Crossrefs

Programs

  • Haskell
    a160000 n = p (takeWhile (<= n) $ sort $ a070165_row n) n where
       p _          0 = 1
       p []         _ = 0
       p ks'@(k:ks) m = if m < k then 0 else p ks' (m - k) + p ks m
    -- Reinhard Zumkeller, Sep 01 2012

A160001 Number of partitions of n into distinct parts occurring in '3x+1'-trajectory starting with n.

Original entry on oeis.org

1, 1, 2, 1, 2, 4, 3, 1, 4, 3, 4, 9, 4, 8, 5, 1, 6, 18, 10, 5, 2, 13, 6, 25, 19, 10, 8, 41, 24, 14, 10, 1, 40, 19, 8, 138, 90, 55, 62, 7, 17, 3, 144, 63, 34, 16, 16, 43, 218, 148, 105, 22, 7, 39, 24, 323, 371, 150, 224, 54, 27, 40, 30, 1, 572, 444, 344, 71, 32, 19, 39, 1766, 52
Offset: 1

Views

Author

Reinhard Zumkeller, May 11 2009

Keywords

Examples

			7-22-11-34-17-52-26-13-40-20-10-5-16-8-[4-2-1]*:
{1,2,4,5,7} is the set of numbers <= n, occurring in this trajectory, therefore a(7) = #{7, 5+2, 4+2+1} = 3.
		

Crossrefs

Programs

  • Haskell
    a160001 n = p (takeWhile (<= n) $ sort $ a070165_row n) n where
       p _      0 = 1
       p []     _ = 0
       p (k:ks) m = if m < k then 0 else p ks (m - k) + p ks m
    -- Reinhard Zumkeller, Sep 01 2012

A214614 Irregular triangle read by rows: row n gives numbers <= n whose Collatz trajectory contains the trajectory of n.

Original entry on oeis.org

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

Views

Author

Jayanta Basu, Mar 06 2013

Keywords

Comments

Each row has A159999(n) elements and ends in n.

Examples

			Rows of triangle:
{1},
{1, 2},
{1, 2, 3},
{1, 2, 4},
{1, 2, 4, 5},
{1, 2, 3, 4, 5, 6},
{1, 2, 4, 5, 7},
{1, 2, 4, 8},
{1, 2, 4, 5, 7, 8, 9},
{1, 2, 4, 5, 8, 10}
		

Crossrefs

Programs

  • Haskell
    import Data.List (sort)
    a214614 n k = a214614_tabf !! (n-1) (k-1)
    a214614_row n = a214614_tabf !! (n-1)
    a214614_tabf = zipWith f [1..] a070165_tabf where
                           f v ws = sort $ filter (<= v) ws
    -- Reinhard Zumkeller, Sep 01 2014
  • Mathematica
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; f[n_] := Module[{c = Collatz[n]}, Select[c, # <= n &]]; t = Table[f[n], {n, 20}]; Flatten[t] (* T. D. Noe, Mar 07 2013 *)

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 *)
Showing 1-7 of 7 results.