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.

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