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

A179118 Number of Collatz steps to reach 1 starting with 2^n + 1.

Original entry on oeis.org

1, 7, 5, 19, 12, 26, 27, 121, 122, 35, 36, 156, 113, 52, 53, 98, 99, 100, 101, 102, 72, 166, 167, 168, 169, 170, 171, 247, 173, 187, 188, 251, 252, 178, 179, 317, 243, 195, 196, 153, 154, 155, 156, 400, 326, 495, 496, 161, 162, 331, 332, 408, 471, 410, 411, 337, 338, 339, 340, 553
Offset: 0

Views

Author

Mitch Harris, Jan 04 2011

Keywords

Comments

There are many long runs of consecutive terms that increase by 1 (see second conjecture in A277109). For n < 40000, the longest run has 1030 terms starting from a(33237) = 244868 and ending with a(34266) = 245897. - Dmitry Kamenetsky, Sep 30 2016

Examples

			a(1)=7 because the trajectory of 2^1+1=3 is (3,10,5,16,8,4,2,1).
		

Crossrefs

Cf. A000051, A006577, A070976, A074472, A075486, A193688 (starting with 2^n-1), , A179118, A277109.

Programs

  • Mathematica
    CollatzNext[n_] := If[Mod[n, 2] == 0, n/2, 3 n + 1]; CollatzPath[n_] := CollatzPath[n] = Module[{k = n, l = {}}, While[k != 1, k = CollatzNext[k]; l = Append[l, k]]; l]; Collatz[n_] := Length[CollatzPath[n]]; Table[Collatz[2^n+1],{n,1,50}]
    f[n_] := Length@ NestWhileList[If[OddQ@ #, 3 # + 1, #/2] &, 2^n + 1, # > 1 &] - 1; Array[f, 60] (* Robert G. Wilson v, Jan 05 2011 *)
    Array[-1 + Length@ NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, 2^# + 1, # > 1 &] &, 60, 0] (* Michael De Vlieger, Nov 25 2018 *)
  • PARI
    nbsteps(n)= s=n; c=0; while(s>1, s=if(s%2, 3*s+1, s/2); c++); c;
    a(n) = nbsteps(2^n+1); \\ Michel Marcus, Oct 28 2018
  • Python
    def steps(a):
      if a==1:     return 0
      elif a%2==0: return 1+steps(a//2)
      else:        return 1+steps(a*3+1)
    for n in range(60):
      print(n, steps((1<
    				

Formula

a(n) = A006577(2^n+1) = A006577(A000051(n)).
a(n) = A075486(n) - 1. - T. D. Noe, Jan 17 2013

Extensions

a(0)=1 prepended by Alois P. Heinz, Dec 12 2018

A213214 Number of steps to reach 1 in the Collatz (3x+1) problem starting with 3^n - 1.

Original entry on oeis.org

1, 3, 10, 9, 96, 95, 32, 31, 43, 42, 134, 133, 132, 131, 99, 98, 190, 189, 139, 138, 261, 260, 427, 426, 394, 393, 330, 329, 390, 389, 388, 387, 461, 460, 459, 458, 457, 456, 455, 454, 453, 452, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 746, 745, 488
Offset: 1

Views

Author

Michel Lagneau, Mar 02 2013

Keywords

Comments

It is interesting to note that the quantity 3^n - 1 appears in the Collatz trajectory of 2^n - 1 after n iterations (see the formula).

Examples

			a(8) = 31 because A193688(8)=47, and 47 - 2*8 = 31.
		

Crossrefs

Programs

  • Mathematica
    f[n_]:=Module[{a=3^n-1, k=0}, While[a>1, k++; If[EvenQ[a], a=a/2, a=a*3+1]]; k]; Table[f[n], {n,100}]
    Table[Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,3^n-1,#>1&]]-1,{n,100}] (* Harvey P. Dale, Sep 06 2015 *)

Formula

a(n) = A193688(n) - 2*n for n > 1.

A181777 Number of steps to reach 1 in '3x+1' (or Collatz) problem starting with the n-th Mersenne prime.

Original entry on oeis.org

7, 16, 106, 46, 158, 224, 177, 450, 860, 1454, 1441, 1660, 6769, 8494, 17094, 29821, 30734, 43478, 55906, 60716, 129608, 134345, 153505, 265860, 293161, 312164, 598067, 1158876, 1482529, 1771117, 2906179, 10197081, 11568589, 16927967, 18807193, 40055567, 40663017, 93778449, 181209792, 282515044, 323346876, 349304386, 409093991, 438465334, 499902411, 573966881, 580260946
Offset: 1

Views

Author

Frank M Jackson, Dec 23 2012

Keywords

Comments

Sequence currently gives the data for the 48 known Mersenne primes (A000043).
It is conjectured by Ohira and Watanabe that for large Mersenne primes 2^k-1, the fraction steps/k ~ 2+3*log(3)/log(4/3) or approximately 13.45.
The confirmed number of steps to reach 1 for other known Mersenne primes S(Mp) above 45th (M37156667): S(M42643801) = 573966881, S(M43112609) = 580260946, S(M57885161) = 779044992, S(M74207281) = 998401306. - Andrey S. Shchebetov and Sergei D. Shchebetov, Nov 14 2017
S(M77232917) = 1039248803. - Andrey S. Shchebetov and Sergei D. Shchebetov, Apr 25 2018
S(M82589933) = 1111148968. Also confirming all previous results. - Martin Raab, Apr 28 2023
S(M136279841) = 1833585702. - Roderick MacPhee, Oct 21 2024

Examples

			a(1)=7 as the first Mersenne prime is 3. So starting at 3 the steps are 10, 5, 16, 8, 4, 2, 1.
		

Crossrefs

Programs

  • Mathematica
    collatz[k_] := (If[OddQ[k], j=3k+1, j=k/2]; j); step[m_] := (p=1; n=m; While[n!=1, (n=collatz[n]; p++)]; p-1); list = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951}; Table[step[2^s-1], {s,list}] (* warning: the list should be limited so as to run in a reasonable amount of time *)
  • PARI
    \\ See Raab link. \\ Martin Raab, May 11 2023

Extensions

a(43)-a(45) from Andrey S. Shchebetov and Sergei D. Shchebetov, Sep 22 2017
Edited by N. J. A. Sloane, Sep 26 2017
a(46)-a(47) from Sergei D. Shchebetov, Apr 25 2018
a(48) from Roderick MacPhee, Oct 21 2024
Showing 1-3 of 3 results.