OFFSET
0,2
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
LINKS
Dmitry Kamenetsky, Table of n, a(n) for n = 0..9999 (terms n = 1...1000 from Mitch Harris)
MathOverflow, Introduced on Mathoverflow by Henrik RĂ¼ping
FORMULA
EXAMPLE
a(1)=7 because the trajectory of 2^1+1=3 is (3,10,5,16,8,4,2,1).
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 *)
PROG
(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<<n)+1))
(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Mitch Harris, Jan 04 2011
EXTENSIONS
a(0)=1 prepended by Alois P. Heinz, Dec 12 2018
STATUS
approved