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

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

A006877 In the '3x+1' problem, these values for the starting value set new records for number of steps to reach 1.

Original entry on oeis.org

1, 2, 3, 6, 7, 9, 18, 25, 27, 54, 73, 97, 129, 171, 231, 313, 327, 649, 703, 871, 1161, 2223, 2463, 2919, 3711, 6171, 10971, 13255, 17647, 23529, 26623, 34239, 35655, 52527, 77031, 106239, 142587, 156159, 216367, 230631, 410011, 511935, 626331, 837799
Offset: 1

Views

Author

Keywords

Comments

Both the 3x+1 steps and the halving steps are counted.
This sequence without a(2) = 2 specifies where records occur in A208981. - Omar E. Pol, Apr 14 2022

References

  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 400.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Maple
    A006877 := proc(n) local a,L; L := 0; a := n; while a <> 1 do if a mod 2 = 0 then a := a/2; else a := 3*a+1; fi; L := L+1; od: RETURN(L); end;
  • Mathematica
    numberOfSteps[x0_] := Block[{x = x0, nos = 0}, While [x != 1 , If[Mod[x, 2] == 0 , x = x/2, x = 3*x + 1]; nos++]; nos]; a[1] = 1; a[n_] := a[n] = Block[{x = a[n-1] + 1}, record = numberOfSteps[x - 1]; While[ numberOfSteps[x] <= record, x++]; x]; A006877 = Table[ Print[a[n]]; a[n], {n, 1, 44}](* Jean-François Alcover, Feb 14 2012 *)
    DeleteDuplicates[Table[{n,Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]]},{n,838000}],GreaterEqual[#1[[2]],#2[[2]]]&][[All,1]] (* Harvey P. Dale, May 13 2022 *)
  • PARI
    A006577(n)=my(s);while(n>1,n=if(n%2,3*n+1,n/2);s++);s
    step(n,r)=my(t);forstep(k=bitor(n,1),2*n,2,t=A006577(k);if(t>r,return([k,t])));[2*n,r+1]
    r=0;print1(n=1);for(i=1,100,[n,r]=step(n,r); print1(", "n)) \\ Charles R Greathouse IV, Apr 01 2013
    
  • Python
    c1 = lambda x: (3*x+1 if (x%2) else x>>1)
    r = -1
    for n in range(1, 10**5):
        a=0 ; n1=n
        while n>1: n=c1(n); a+=1;
        if a > r: print(n1, end = ', '); r=a
    print('...') # Ya-Ping Lu and Robert Munafo, Mar 22 2024

A006884 In the '3x+1' problem, these values for the starting value set new records for highest point of trajectory before reaching 1.

Original entry on oeis.org

1, 2, 3, 7, 15, 27, 255, 447, 639, 703, 1819, 4255, 4591, 9663, 20895, 26623, 31911, 60975, 77671, 113383, 138367, 159487, 270271, 665215, 704511, 1042431, 1212415, 1441407, 1875711, 1988859, 2643183, 2684647, 3041127, 3873535, 4637979, 5656191
Offset: 1

Views

Author

Keywords

Comments

Both the 3x+1 steps and the halving steps are counted.
Where records occur in A025586: A006885(n) = A025586(a(n)) and A025586(m) < A006885(n) for m < a(n). - Reinhard Zumkeller, May 11 2013

References

  • R. B. Banks, Slicing Pizzas, Racing Turtles and Further Adventures in Applied Mathematics, Princeton Univ. Press, 1999. See p. 96.
  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 400.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

A060409 gives associated "dropping times", A060410 the maximal values and A060411 the steps at which the maxima occur.

Programs

  • Haskell
    a006884 n = a006884_list !! (n-1)
    a006884_list = f 1 0 a025586_list where
       f i r (x:xs) = if x > r then i : f (i + 1) x xs else f (i + 1) r xs
    -- Reinhard Zumkeller, May 11 2013
    
  • Mathematica
    mcoll[n_]:=Max@@NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]; t={1,max=2}; Do[If[(y=mcoll[n])>max,max=y; AppendTo[t,n]],{n,3,705000,4}]; t (* Jayanta Basu, May 28 2013 *)
    DeleteDuplicates[Parallelize[Table[{n,Max[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]]},{n,57*10^5}]],GreaterEqual[#1[[2]],#2[[2]]]&][[;;,1]] (* Harvey P. Dale, Apr 23 2023 *)
  • PARI
    A025586(n)=my(r=n); while(n>2, if(n%2, n=3*n+1; if(n>r, r=n)); n>>=1); r
    r=0; for(n=1,1e6, t=A025586(n); if(t>r, r=t; print1(n", "))) \\ Charles R Greathouse IV, May 25 2016

A006878 Record number of steps to reach 1 in '3x+1' problem, corresponding to starting values in A006877.

Original entry on oeis.org

0, 1, 7, 8, 16, 19, 20, 23, 111, 112, 115, 118, 121, 124, 127, 130, 143, 144, 170, 178, 181, 182, 208, 216, 237, 261, 267, 275, 278, 281, 307, 310, 323, 339, 350, 353, 374, 382, 385, 442, 448, 469, 508, 524, 527, 530, 556, 559, 562, 583, 596, 612, 664, 685, 688, 691, 704
Offset: 1

Views

Author

Keywords

Comments

Both the 3x+1 steps and the halving steps are counted.

References

  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 400.
  • G. T. Leavens and M. Vermeulen, 3x+1 search problems, Computers and Mathematics with Applications, 24 (1992), 79-99.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Maple
    f := proc(n) local a,L; L := 0; a := n; while a <> 1 do if a mod 2 = 0 then a := a/2; else a := 3*a+1; fi; L := L+1; od: RETURN(L); end;
  • Mathematica
    numberOfSteps[x0_] := Block[{x = x0, nos = 0}, While[x != 1, If[Mod[x, 2] == 0, x = x/2, x = 3*x+1]; nos++]; nos]; A006878 = numberOfSteps /@ A006877 (* Jean-François Alcover, Feb 22 2012 *)
    DeleteDuplicates[Table[Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]],{n,0,10^6}],GreaterEqual]-1 (* The program generates the first 44 terms of the sequence, derived from all starting values from 1 up to and including 1 million. *) (* Harvey P. Dale, Nov 26 2022 *)

A033492 Record number of steps to reach 1 in '3x+1' problem, corresponding to starting values in A006877 (same as A006878 except here we start counting at 1 instead of 0).

Original entry on oeis.org

1, 2, 8, 9, 17, 20, 21, 24, 112, 113, 116, 119, 122, 125, 128, 131, 144, 145, 171, 179, 182, 183, 209, 217, 238, 262, 268, 276, 279, 282, 308, 311, 324, 340, 351, 354, 375, 383, 386, 443, 449, 470, 509, 525, 528, 531, 557, 560, 563, 584, 597, 613, 665, 686
Offset: 1

Views

Author

Keywords

Comments

Both the 3x+1 steps and the halving steps are counted.

References

  • R. E. Maeder, Programming in Mathematica, 3rd Edition, Addison-Wesley, pages 251-252.

Crossrefs

Equal to A006878 + 1. Cf. A006884, A006885, A033492.

Extensions

Corrected and extended by Lee Corbin (lcorbin(AT)tsoft.com)
More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001

A033958 In the '3x+1' problem, these values for the starting value set new records for number of steps to reach 1.

Original entry on oeis.org

1, 3, 7, 9, 25, 27, 73, 97, 129, 171, 231, 313, 327, 703, 871, 1161, 2463, 2919, 3711, 6171, 10971, 13255, 17647, 23529, 26623, 34239, 35655, 52527, 77031, 106239, 142587, 156159, 216367, 230631, 410011, 511935, 626331, 837799, 1117065, 1501353, 1723519, 2298025, 3064033
Offset: 1

Views

Author

Keywords

Comments

Only the 3x+1 steps, not the halving steps, are counted.

References

  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 400.
  • G. T. Leavens and M. Vermeulen, 3x+1 search problems, Computers and Mathematics with Applications, 24 (1992), 79-99.

Crossrefs

Programs

  • Haskell
    a033958 n = a033958_list !! (n-1)
    -- For definition of a033958_list: see A033959.
    -- Reinhard Zumkeller, Jan 08 2014
  • Mathematica
    f[ nn_ ] := Module[ {c, n}, c = 0; n = nn; While[ n != 1, If[ Mod[ n, 2 ] == 0, n /= 2, n = 3*n + 1; c++ ] ]; Return[ c ] ] maxx = -1; For[ n = 1, n <= 10^8, n++, Module[ {val}, val = f[ n ]; If[ val > maxx, maxx = val; Print[ n, " ", val ] ] ] ] (* Winston C. Yang (winston(AT)cs.wisc.edu), Aug 27 2000 *)

Formula

Positions of records in A006667. - Sean A. Irvine, Jul 22 2020

Extensions

More terms from Jud McCranie, Jan 26 2000
Corrected with Mathematica code by Winston C. Yang (winston(AT)cs.wisc.edu), Aug 27 2000
a(40)-a(43) from Charles R Greathouse IV, Oct 07 2013

A075684 For odd numbers 2n-1, the maximum number produced by iterating the reduced Collatz function R defined as R(k) = (3k+1)/2^r, with r as large as possible.

Original entry on oeis.org

1, 5, 5, 17, 17, 17, 13, 53, 17, 29, 21, 53, 29, 3077, 29, 3077, 33, 53, 37, 101, 3077, 65, 45, 3077, 49, 77, 53, 3077, 65, 101, 61, 3077, 65, 101, 69, 3077, 3077, 113, 77, 269, 81, 3077, 85, 197, 101, 3077, 93, 3077, 3077, 149, 101, 3077, 269, 3077, 3077, 3077
Offset: 1

Views

Author

T. D. Noe, Sep 25 2002

Keywords

Comments

See A075677 for the function R applied to the odd numbers once. See A075680 for the number of iterations required to yield 1. Sequence A006884, with the number 2 removed, gives the odd numbers that produce new record maxima. The maxima of the current sequence are related to A006885: if m is a maximum of the usual Collatz iteration, then (m-1)/3 is the maximum for the reduced Collatz iteration.

Examples

			a(4) = 17 because 7 is the fourth odd number and 17 is the largest number in the iteration: R(7)=11, R(11)=17, R(17)=13, R(13)=5, R(5)=1.
		

Crossrefs

Programs

  • Mathematica
    nextOddK[n_] := Module[{m=3n+1}, While[EvenQ[m], m=m/2]; m]; (* assumes odd n *) Table[m=n; maxK=n; If[n>1, While[m=nextOddK[m]; maxK=Max[m, maxK]; m!=1]]; maxK, {n, 1, 200, 2}]

A095384 Number of different initial values for 3x+1 trajectories started with initial values not exceeding 2^n and in which the peak values are also not larger than 2^n.

Original entry on oeis.org

1, 2, 3, 4, 10, 13, 33, 55, 112, 181, 352, 580, 1072, 2127, 6792, 13067, 25906, 51447, 104575, 208149, 415921, 833109, 1661341, 3328124, 6648354, 13283680, 26533708, 53083687, 106166631, 212243709, 424564626, 848967377, 1698139390, 3396064464, 6791623786
Offset: 0

Views

Author

Labos Elemer, Jun 14 2004

Keywords

Examples

			n=4: between iv={1,2,...,16} {2,8}U{3,5,6,10,12,16} provides peak values smaller than or equal with 16, so a(4) = 10 = A087256(4)+4
		

Crossrefs

Programs

  • Maple
    b:= proc(n) option remember; `if`(n=1, 1,
          max(n, b(`if`(n::even, n/2, 3*n+1))))
        end:
    a:= proc(n) option remember; local t; t:=2^n;
          add(`if`(b(i)<=t, 1, 0), i=1..t)
        end:
    seq(a(n), n=0..20);  # Alois P. Heinz, Sep 26 2024
  • Mathematica
    c[x_]:=c[x]=(1-Mod[x, 2])*(x/2)+Mod[x, 2]*(3*x+1);c[1]=1; fpl[x_]:=FixedPointList[c, x]; {$RecursionLimit=1000;m=0}; Table[Print[{xm-1, m}];m=0; Do[If[ !Greater[Max[fpl[n]], 2^xm], m=m+1], {n, 1, 2^xm}], {xm, 1, 30}]
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; Table[Length[Select[Range[x=2^n], Max[Collatz[#]] <= x &]], {n,0,10}] (* T. D. Noe, Apr 29 2013 *)

Extensions

a(21)-a(32) from Donovan Johnson, Feb 02 2011
a(0) from T. D. Noe, Apr 29 2013
a(33)-a(34) from Donovan Johnson, Jun 05 2013

A033959 Record number of steps to reach 1 in '3x+1' problem, corresponding to starting values in A033958.

Original entry on oeis.org

0, 2, 5, 6, 7, 41, 42, 43, 44, 45, 46, 47, 52, 62, 65, 66, 76, 79, 87, 96, 98, 101, 102, 103, 113, 114, 119, 125, 129, 130, 138, 141, 142, 164, 166, 174, 189, 195, 196, 197, 207, 208, 209, 217, 222, 228, 248, 256, 257, 258, 263, 278, 357, 358, 359, 362, 370
Offset: 1

Views

Author

Keywords

Comments

Only the 3x+1 steps, not the halving steps, are counted.

References

  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 400.
  • G. T. Leavens and M. Vermeulen, 3x+1 search problems, Computers and Mathematics with Applications, 24 (1992), 79-99.

Crossrefs

Programs

  • Haskell
    a033959 n = a033959_list !! (n-1)
    (a033959_list, a033958_list) = unzip $ (0, 1) : f 1 1 where
       f i x | y > x     = (y, 2 * i - 1) : f (i + 1) y
             | otherwise = f (i + 1) x
             where y = a075680 i
    -- Reinhard Zumkeller, Jan 08 2014
  • Maple
    A033959 := proc(n) local a,L; L := 0; a := n; while a <> 1 do if a mod 2 = 0 then a := a/2; else a := 3*a+1; L := L+1; fi; od: RETURN(L); end;
  • Mathematica
    f[ nn_ ] := Module[ {c, n}, c = 0; n = nn; While[ n != 1, If[ Mod[ n, 2 ] == 0, n /= 2, n = 3*n + 1; c++ ] ]; Return[ c ] ] maxx = -1; For[ n = 1, n <= 10^8, n++, Module[ {val}, val = f[ n ]; If[ val > maxx, maxx = val; Print[ n, " ", val ] ] ] ]

Extensions

More terms from Winston C. Yang (winston(AT)cs.wisc.edu), Aug 27 2000
More terms from Larry Reeves (larryr(AT)acm.org), Sep 27 2000
Offset corrected by Reinhard Zumkeller, Jan 08 2014

A224538 Number of numbers k such that all terms of the Collatz (3x+1) iteration of k are <= 10^n.

Original entry on oeis.org

1, 4, 49, 340, 4235, 39706, 397068, 3970918, 39523168, 395436300, 3953296865
Offset: 0

Views

Author

T. D. Noe, Apr 24 2013

Keywords

Examples

			For n = 1, the four k are 1, 2, 4, and 8.
		

Crossrefs

Programs

  • Mathematica
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; Table[Length[Select[Range[10^n], Max[Collatz[#]] <= 10^n &]], {n, 0, 5}]

Extensions

a(10) from Donovan Johnson, Jun 05 2013
Showing 1-10 of 13 results. Next