OFFSET
1,2
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.
LINKS
Brian Hayes, Computer Recreations: On the ups and downs of hailstone numbers, Scientific American, 250 (No. 1, 1984), pp. 10-16.
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 ] ] ] ]
PROG
(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
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
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
STATUS
approved