OFFSET
1,1
COMMENTS
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..1000
Eric Weisstein's World of Mathematics, Collatz Problem
Wikipedia, Collatz conjecture
EXAMPLE
n, f(n), f(f(n)), .... for n = 21 is: 21, 64, 32, 16, 8, 4, 2, 1, which has exactly one prime, that is, 2. Hence 21 belongs to the sequence.
MATHEMATICA
f[n_] := n/2 /; Mod[n, 2] == 0 f[n_] := 3 n + 1 /; Mod[n, 2] == 1 g[n_] := Module[{i, p}, i = n; p = 0; While[i > 1, If[PrimeQ[i], p = p + 1]; i = f[i]]; p]; Select[Range[10^4], g[ # ] == 1 && ! IntegerQ[Log[2, # ]] &]
pQ[n_]:=Count[NestWhileList[If[EvenQ[#], #/2, 3#+1]&, n, #>1&], _?PrimeQ] == 1; With[ {nn=10000}, Complement[Select[Range[nn], pQ], 2^Range[Floor[ Log[ 2, nn]]]]] (* Harvey P. Dale, Oct 19 2011 *)
PROG
(Haskell)
a078440 n = a078440_list !! (n-1)
a078440_list = filter notbp a196871_list where
notbp x = m > 0 && x > 1 || m == 0 && notbp x' where
(x', m) = divMod x 2
-- Reinhard Zumkeller, Oct 08 2011
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph L. Pe, Dec 31 2002
STATUS
approved