OFFSET
1,2
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, E16.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
M. Elia, Letter to N. J. A. Sloane, Jun. 1981
J. C. Lagarias, The 3x+1 problem and its generalizations, Amer. Math. Monthly, 92 (1985), 3-23.
FORMULA
For n > 2: a(n) = 4 if L = 0, otherwise L, where L = A139399(n) mod 3. - Reinhard Zumkeller, Nov 16 2013
MATHEMATICA
f[n_] := If[EvenQ[n], n/2, 3 n + 1];
a[n_] := With[{ff = NestWhileList[f, n, {#1, #2, #3} != {4, 2, 1}&, 3]}, ff[[Switch[Mod[Length[ff], 3], 0, -3, 1, -1, 2, -2]]]];
Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Aug 08 2022 *)
PROG
(Haskell)
a006460 = f 0 where
f k x | mod k 3 == 0 && x `elem` [1, 2, 4] = x
| otherwise = f (k+1) (a006370 x)
-- Reinhard Zumkeller, Nov 16 2013
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
EXTENSIONS
More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001
STATUS
approved