A078719 Number of odd terms among n, f(n), f(f(n)), ...., 1 for the Collatz function (that is, until reaching "1" for the first time), or -1 if 1 is never reached.
1, 1, 3, 1, 2, 3, 6, 1, 7, 2, 5, 3, 3, 6, 6, 1, 4, 7, 7, 2, 2, 5, 5, 3, 8, 3, 42, 6, 6, 6, 40, 1, 9, 4, 4, 7, 7, 7, 12, 2, 41, 2, 10, 5, 5, 5, 39, 3, 8, 8, 8, 3, 3, 42, 42, 6, 11, 6, 11, 6, 6, 40, 40, 1, 9, 9, 9, 4, 4, 4, 38, 7, 43, 7, 4, 7, 7, 12, 12, 2, 7, 41, 41, 2, 2, 10, 10, 5, 10, 5, 34, 5, 5, 39
Offset: 1
Keywords
Examples
The terms n, f(n), f(f(n)), ...., 1 for n = 12 are: 12, 6, 3, 10, 5, 16, 8, 4, 2, 1, of which 3 are odd. Hence a(12) = 3.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- Chris K. Caldwell and G. L. Honaker, Jr., Prime curio for 41 (which says 41 is a fixed point)
- Eric Weisstein's World of Mathematics, Collatz Problem
- Wikipedia, Collatz conjecture
- Index entries for sequences related to 3x+1 (or Collatz) problem
Programs
-
Haskell
a078719 = (+ 1) . length . filter odd . takeWhile (> 2) . (iterate a006370) a078719_list = map a078719 [1..] -- Reinhard Zumkeller, Oct 08 2011
-
Maple
a:= proc(n) option remember; `if`(n<2, 1, `if`(n::even, a(n/2), 1+a(3*n+1))) end: seq(a(n), n=1..94); # Alois P. Heinz, Jan 17 2025
-
Mathematica
f[n_] := Module[{a, i, o}, i = n; o = 1; a = {}; While[i > 1, If[Mod[i, 2] == 1, o = o + 1]; a = Append[a, i]; i = f[i]]; o]; Table[f[i], {i, 1, 100}] Table[Count[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &], ?OddQ], {n, 94}] (* _Jayanta Basu, Jun 15 2013 *)
-
PARI
a(n) = {my(x=n, v=List([])); while(x>1, if(x%2==0, x=x/2, listput(v, x); x=3*x+1)); 1+#v;} \\ Jinyuan Wang, Dec 29 2019
Formula
Extensions
"Escape clause" added to definition by N. J. A. Sloane, Jun 06 2017
Comments