OFFSET
1,2
COMMENTS
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..10000
EXAMPLE
n=2k: then a(2k)=2 because the second iterate is k<n=2k, the first iterate below 2k; n=4k+1, k>1: the list = {4k+1, 12k+4, 6k+2, 3k+1, ...} i.e. the 4th term is always the first below initial value, so a(4k+1)=4;
n=15: the list={15, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1} and 12th term is first sinks below iv=15, so a(15)=12; relatively larger values occur at n=4k+3.
n=3: the list is {3, 10, 5, 16, 8, 4, 2, 1, ..}, the 7th term is 2, which is the first smaller than 3, so a(3)=7.
MATHEMATICA
nextx[x_Integer] := If[OddQ@x, 3x + 1, x/2]; f[1] = 1; f[n_] := Length@ NestWhileList[nextx, n, # >= n &]; Array[f, 83] (* Bobby R. Treat (drbob(at)bigfoot.com), Sep 16 2006 *)
PROG
(Python)
def a(n):
if n<3: return n
N=n
x=1
while True:
if n%2==0: n/=2
else: n = 3*n + 1
x+=1
if n<N: return x
[a(n) for n in range(1, 101)] # Indranil Ghosh, Apr 15 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Labos Elemer, Sep 19 2002
EXTENSIONS
Edited by N. J. A. Sloane, Sep 15 2006
STATUS
approved